/*****************Position Reports charts Starts here*****************************/
$(document).ready(function() {
	/**
	 * To show data reloading on refresh chart event
	 */
	function insertDataReloadDiv(element){
		 $(element).append('<div class="loaddiv"></div>');
	}
	//-----------------Report by Counter party Starts Here----------------------//
	//$("#reload-bar").show();
	var checked = 'true';
	var productByCpJsonBarSeriesData = new Array();
	var productByCpJsonBarCategories = new Array();
	var productByCpJson = new Array();
	$("#PositionbyCounterpartyRefresh").on('click', function(element){
		insertDataReloadDiv(element.currentTarget);
		//insertDataReloadDiv(element);
		//$('.loaddiv').show();
		productByCpJson = [];
		productByCpJsonBarSeriesData = [];
		productByCpJsonBarCategories = [];
		$.getJSON(
				ezopsContextPath
						+ '/getReports/getpositionbycppiechart?refresh=true',
				function(data) {
					//console.log('productByCpJson---'+productByCpJson);
					for ( var i = 0, len = data.length; i < len; i++) {
						productByCpJsonBarCategories.push([data[i].partyId]);
						productByCpJsonBarSeriesData.push([parseInt(data[i].agreementTypeCount)]);
						productByCpJson.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
					}
					getPositionByCpReport(productByCpJson);
					$('.loaddiv').hide();
				});
});


			$.getJSON(
					ezopsContextPath
							+ '/getReports/getpositionbycppiechart',
					function(data) {

						for ( var i = 0, len = data.length; i < len; i++) {
							productByCpJsonBarCategories.push([data[i].partyId]);
							productByCpJsonBarSeriesData.push([parseInt(data[i].agreementTypeCount)]);
							productByCpJson.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
						}
						getPositionByCpReport(productByCpJson);
					});
	$('#poscp-chart-view1').on('click', function(event) {
		console.log('checked'+checked);
		if(checked == 'true'){
			console.log('Checked');
			$('#PositionbyCounterpartyChart')
			.highcharts(
					{
						chart : {
							type : 'bar'
						},

						title : {
							text : ''
						},
						subtitle : {
							text : ''
						},

						xAxis : {
							categories : productByCpJsonBarCategories
						},
						credits : {
							enabled : false
						},
						series : [ {
							name : 'Positions',
							data : productByCpJsonBarSeriesData

						} ]
					});

			

			checked = 'false';
		}
		else{
			checked = 'true';
			getPositionByCpReport(productByCpJson);
		}
		
	});

//-----------------POsition by Counter party Starts Here -------------------------//
// get the procuduct by cp report from server and create report

function getPositionByCpReport(productByCpJson) {
						// Build the chart4
						console.log('processed_json');
						//console.log(productByCpJson);
						$('#PositionbyCounterpartyChart')
						.highcharts(
								{
									chart : {
										plotBackgroundColor : null,
										plotBorderWidth : null,
										plotShadow : false
									},
									title : {
										text : ''
									},
									tooltip : {
										pointFormat : 'Positions: <b>{point.percentage:.1f}%</b>'
									},
									plotOptions : {
										pie : {
											allowPointSelect : true,
											cursor : 'pointer',
											dataLabels : {
												enabled : false
											},
											showInLegend : true
										}
									},
									series : [ {
										type : 'pie',
										name : '',
										data : productByCpJson
									} ]
								});
			}
//-----------------Report by Counter party Ends Here----------------------//

//-----------------Position by Product Starts Here -------------------------//
var positionByProductChecked = 'true';
var positionByProductBarSeriesArr = new Array();
var positionByProductBarCategoriesArr = new Array();
var positionByProductArr = new Array();
$("#PositionbyCounterpartyAccTypeRefresh").on('click', function(element){
	insertDataReloadDiv(element.currentTarget);
	//$('.loaddiv1').show();
	//insertDataReloadDiv(element);
	positionByProductArr = [];
	positionByProductBarSeriesArr = [];
	positionByProductBarCategoriesArr = [];
$.getJSON(
		ezopsContextPath + '/getReports/getpositionbyproductpiechart?refresh=true',
		function(data) {
			for ( var i = 0, len = data.length; i < len; i++) {
				positionByProductArr.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
				positionByProductBarSeriesArr.push([parseInt(data[i].agreementTypeCount)]);
				positionByProductBarCategoriesArr.push([ data[i].partyId]);
			}
			console.log('Calling getPositionByProductReport....');
			getPositionByProductReport(positionByProductArr);
			$('.loaddiv').hide();
		});
});

$.getJSON(
		ezopsContextPath + '/getReports/getpositionbyproductpiechart',
		function(data) {
			for ( var i = 0, len = data.length; i < len; i++) {
				positionByProductArr.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
				positionByProductBarSeriesArr.push([parseInt(data[i].agreementTypeCount)]);
				positionByProductBarCategoriesArr.push([ data[i].partyId]);
			}
			console.log('Calling getPositionByProductReport....');
			getPositionByProductReport(positionByProductArr);
		});

$('#posprod-chart-view1').on('click', function() {
	if(positionByProductChecked == 'true'){
		console.log('Checked');
		$('#PositionbyCounterpartyAccTypeChart')
		.highcharts(
				{
					chart : {
						plotBackgroundColor : null,
						plotBorderWidth : null,
						plotShadow : false
					},
					title : {
						text : ''
					},
					tooltip : {
						pointFormat : 'Quantity: <b>{point.percentage:.1f}%</b>'
					},
					plotOptions : {
						pie : {
							allowPointSelect : true,
							cursor : 'pointer',
							dataLabels : {
								enabled : false
							},
							showInLegend : true
						}
					},
					series : [ {
						type : 'pie',
						name : '',
						data : positionByProductArr
					} ]
				});

		positionByProductChecked = 'false';
	}
	else{
		positionByProductChecked = 'true';
		getPositionByProductReport(positionByProductArr);
	}
	
});

function getPositionByProductReport(positionByProductArr) {
	console.log('Called getPositionByProductReport....');
	//console.log('Data Used####'+positionByProductArr);

						// Build the chart4
						console.log('processed_json');
						//console.log(positionByProductArr);
						$('#PositionbyCounterpartyAccTypeChart')
						.highcharts(
								{
									chart : {
										type : 'bar'
									},

									title : {
										text : ''
									},
									subtitle : {
										text : ''
									},

									xAxis : {
										categories : positionByProductBarCategoriesArr
									},
									credits : {
										enabled : false
									},
									series : [ {
										name : 'Positions',
										data : positionByProductBarSeriesArr

									} ]
								});
											//});
						console.log('Call finished');

}



//-----------------Position by Product Ends Here -------------------------//

//-----------------Position by Currency Starts Here -------------------------//
var positionByCurrChecked = 'true';
var positionByCurrBarSeriesArr = new Array();
var positionByCurrBarCategoriesArr = new Array();
var positionByCurrArr = new Array();
$("#PositionbyCounterpartyCurrencyRefresh").on('click', function(element){
	insertDataReloadDiv(element.currentTarget);
	positionByCurrArr = [];
	positionByCurrBarSeriesArr = [];
	positionByCurrBarCategoriesArr = [];
	$.getJSON(
			ezopsContextPath
					+ '/getReports/getpositionbycurrencypiechart?refresh=true',
			function(data) {

				for ( var i = 0, len = data.length; i < len; i++) {
					positionByCurrArr.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
					positionByCurrBarSeriesArr.push([ parseInt(data[i].agreementTypeCount) ]);
					positionByCurrBarCategoriesArr.push([ data[i].partyId ]);
				}
				getPositionByCurrencyReport(positionByCurrArr);
				$('.loaddiv').hide();
			});
});

$.getJSON(
		ezopsContextPath
				+ '/getReports/getpositionbycurrencypiechart',
		function(data) {

			for ( var i = 0, len = data.length; i < len; i++) {
				positionByCurrArr.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
				positionByCurrBarSeriesArr.push([ parseInt(data[i].agreementTypeCount) ]);
				positionByCurrBarCategoriesArr.push([ data[i].partyId ]);
			}
			getPositionByCurrencyReport(positionByCurrArr);
		});

$('#poscurr-chart-view1').on('click', function() {
	if(positionByCurrChecked == 'true'){
		console.log('Checked');
		//console.log('positionByCurrBarSeriesArr##'+positionByCurrBarSeriesArr);
		//console.log('positionByCurrBarCategoriesArr##'+positionByCurrBarCategoriesArr);
		$('#PositionbyCounterpartyCurrencyChart')
		.highcharts(
				{
					chart : {
						type : 'bar'
					},

					title : {
						text : ''
					},
					subtitle : {
						text : ''
					},

					xAxis : {
						categories : positionByCurrBarCategoriesArr
					},
					credits : {
						enabled : false
					},
					series : [ {
						name : 'Positions',
						data : positionByCurrBarSeriesArr
					} ]
				});
		

		
		positionByCurrChecked = 'false';
	}
	else{
		positionByCurrChecked = 'true';
		getPositionByCurrencyReport(positionByCurrArr);
	}
	
});

function getPositionByCurrencyReport(positionByCurrArr) {

						// Build the chart4
						console.log('processed_json');
						//console.log(positionByCurrArr);
						$('#PositionbyCounterpartyCurrencyChart')
						.highcharts(
								{
									chart : {
										plotBackgroundColor : null,
										plotBorderWidth : null,
										plotShadow : false
									},
									title : {
										text : ''
									},
									tooltip : {
										pointFormat : 'Positions: <b>{point.percentage:.1f}%</b>'
									},
									plotOptions : {
										pie : {
											allowPointSelect : true,
											cursor : 'pointer',
											dataLabels : {
												enabled : false
											},
											showInLegend : true
										}
									},
									series : [ {
										type : 'pie',
										name : '',
										data : positionByCurrArr
									} ]
								});
						
						
						
											//});
}
//});
// -------Position by Currency Ends Here-----------//
/*****************Position Reports charts Ends here*****************************/

/*****************Cash Management Reports charts Starts here*****************************/
//$(document).ready(function () {
    
   // prepare the data
	//var positionByCurrChecked = 'true';
	var cashBalanceBarSeriesArr = new Array();
	var cashBalanceBarCategoriesArr = new Array();
	var cashBalanceBarSeriesAmtArr = new Array();
	$.getJSON(
			ezopsContextPath
					+ '/getReports/getcashbalanceschart',
			function(data) {
				cashBalanceBarCategoriesArr = data.valueDates;
				cashBalanceBarSeriesArr =data.cashBalanceCurrencyAmountModel;
				//console.log('@@'+ko.toJSON(cashBalanceBarCategoriesArr)+'	'+ko.toJSON(cashBalanceBarSeriesArr));
				getCashBalanceBarData(cashBalanceBarCategoriesArr,cashBalanceBarSeriesArr);
			});
	
	function getCashBalanceBarData(cashBalanceBarCategoriesArr,cashBalanceBarSeriesArr){
		$(function() {
			$('#cashbalancesbar')
			.highcharts(
					{
						chart : {
							type : 'column'
						},
						title : {
							text : ''
						},
						subtitle : {
							text : ''
						},
						xAxis : {
							categories : cashBalanceBarCategoriesArr
						},
						yAxis : {
							min : 0,
							title : {
								text : ''
							}
						},
						tooltip : {
							headerFormat : '<span style="font-size:10px">{point.key}</span><table>',
							pointFormat : '<tr><td style="color:{series.color};padding:0">{series.name}: </td>'
								+ '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
								footerFormat : '</table>',
								shared : true,
								useHTML : true
						},
						plotOptions : {
							column : {
								pointPadding : 0.2,
								borderWidth : 0
							}
						},
						series : cashBalanceBarSeriesArr
					});
		});
	}

    
	   // prepare the data
		//var positionByCurrChecked = 'true';
		var cashBalanceBarSeriesArr = new Array();
		var cashBalanceBarCategoriesArr = new Array();
		var cashBalanceBarSeriesAmtArr = new Array();
		$.getJSON(
				ezopsContextPath
						+ '/getReports/getcashdailychangechart',
				function(data) {
					cashBalanceBarCategoriesArr = data.valueDates;
					cashBalanceBarSeriesArr =data.cashBalanceCurrencyAmountModel;
					//console.log('@@'+ko.toJSON(cashBalanceBarCategoriesArr)+'	'+ko.toJSON(cashBalanceBarSeriesArr));
					getCashDailyChangeBarData(cashBalanceBarCategoriesArr,cashBalanceBarSeriesArr);
				});
		
		function getCashDailyChangeBarData(cashBalanceBarCategoriesArr,cashBalanceBarSeriesArr){
			$(function() {
				$('#CashDailyChangeChart')
				.highcharts(
						{
							chart : {
								type : 'column'
							},
							title : {
								text : ''
							},
							subtitle : {
								text : ''
							},
							xAxis : {
								categories : cashBalanceBarCategoriesArr
							},
							yAxis : {
								min : 0,
								title : {
									text : ''
								}
							},
							tooltip : {
								headerFormat : '<span style="font-size:10px">{point.key}</span><table>',
								pointFormat : '<tr><td style="color:{series.color};padding:0">{series.name}: </td>'
									+ '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
									footerFormat : '</table>',
									shared : true,
									useHTML : true
							},
							plotOptions : {
								column : {
									pointPadding : 0.2,
									borderWidth : 0
								}
							},
							series : cashBalanceBarSeriesArr
						});
			}());
		}
/*****************Cash Management Reports charts Ends here*****************************/

/****************Cash Upcoming Pay Rerceive Chart **************************/
var cashUpcomingBarSeriesData = new Array();
var cashUpcomingBarCategories = new Array();
$.getJSON(
		ezopsContextPath
				+ '/getReports/getcashupcomingpayrecievechart',
		function(data) {
			for ( var i = 0, len = data.length; i < len; i++) {
				cashUpcomingBarCategories.push([data[i].valueDate]);
				//console.log('data[i].valeuDate  '+data[i].valueDate);
				cashUpcomingBarSeriesData.push([parseFloat(data[i].cashAmount)]);
			}
			getCashUpcomingBarData(cashUpcomingBarCategories,cashUpcomingBarSeriesData);
		});

function getCashUpcomingBarData(cashUpcomingBarCategories,cashUpcomingBarSeriesData){
	console.log('cashUpcomingBarCategories '+cashUpcomingBarCategories);
	console.log('cashUpcomingBarSeriesData '+cashUpcomingBarSeriesData);
	$('#CashUpcomingChart')
	.highcharts(
			{
				chart : {
					type : 'bar'
				},

				title : {
					text : ''
				},
				subtitle : {
					text : ''
				},

				xAxis : {
					categories : cashUpcomingBarCategories
				},
				credits : {
					enabled : false
				},
				series : [ {
					name : 'Cash Amount',
					data : cashUpcomingBarSeriesData

				} ]
			});
}



/****************************Risk cash flow chart *************/

    
	   // prepare the data
		//var positionByCurrChecked = 'true';
		var riskCashBarSeriesArr = new Array();
		var riskCashBarCategoriesArr = new Array();
		var riskCashBarSeriesAmtArr = new Array();
		$.getJSON(
				ezopsContextPath
						+ '/getReports/getriskcashflowanalysischart',
				function(data) {
					riskCashBarCategoriesArr = data.valueDates;
					riskCashBarSeriesArr =data.cashBalanceCurrencyAmountModel;
					//console.log('@##'+ko.toJSON(riskCashBarCategoriesArr)+'	'+ko.toJSON(riskCashBarSeriesArr));
					getriskCashFlowBarData(riskCashBarCategoriesArr,riskCashBarSeriesArr);
				});
		
		function getriskCashFlowBarData(riskCashBarCategoriesArr,riskCashBarSeriesArr){
			$(function() {
				$('#RiskCashFlowAnalysisChart')
				.highcharts(
						{
							chart : {
								type : 'bar'
							},
							title : {
								text : ''
							},
							subtitle : {
								text : ''
							},
							xAxis : {
								categories : ["06-Oct","14-Dec","23-Feb","31-Dec"]
							},
							yAxis : {
								min : 0,
								title : {
									text : ''
								}
							},
							tooltip : {
								headerFormat : '<span style="font-size:10px">{point.key}</span><table>',
								pointFormat : '<tr><td style="color:{series.color};padding:0">{series.name}: </td>'
									+ '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
									footerFormat : '</table>',
									shared : true,
									useHTML : true
							},
							plotOptions : {
								column : {
									pointPadding : 0.2,
									borderWidth : 0
								}
							},
							series : [{"data":[1,2,3,3],"name":"GBP"}]
						});
			}());
		}

           var source =
           {
               dataType: "json",
               dataFields: [
                    { name: 'Product.Description', type: 'string' },
                    { name: 'Product.AccountingType', type: 'string' },
                    { name: 'PartyId', type: 'string' },
                    { name: 'SettleCurrency', type: 'string' },
                    { name: 'Quantity', type: 'string' },
                    { name: 'Product.Isin', type: 'string' },
                    { name: 'PositionType', type: 'string' },
                    { name: 'SettleCurrency', type: 'string' }
               ], 
               url: ezopsContextPath+'/getReports/parsecsvforpositioncharts'
           };
           var dataAdapter = new $.jqx.dataAdapter(source, {
               loadComplete: function () {
                   //console.log(dataAdapter);
               }
           });
           var cellClass = function (row, dataField, cellText, rowData) {
               var cellValue = rowData[dataField];
               switch (dataField) {
                   case "diffQuantity":
                       if (cellValue >100 || cellValue < 0) {
                           return "minavg";                            
                       }
                       if (cellValue <= 100 ) {
                           return "max";
                       }                       
                       return "max";
                       
                   case "diffMarketValue":
                       if (cellValue >100 || cellValue < 0) {
                           return "minavg";                            
                       }
                       if (cellValue <= 100 ) {
                           return "max";
                       }                        
                       return "min";                    
               }
           }
           // create jqxDataTable for Position by CP.
           $("#positioncounter1").jqxGrid(
           {
               source: dataAdapter,
               altRows: true,
               width: '99%',
               height: '600',
               sortable: true,
               pageable:false,
               filterable: true,
               groupable: true,
               showstatusbar: true,
               statusbarheight: 50,
               showaggregates: true,
               columnsresize: true,
               columnsreorder: true,

               
               columns: [
                 { text: 'Product', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Product.Description',/* pinned: true,*/  width: '20%' },
                 { text: 'Counterparty', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'PartyId', width: '20%' },
                 { text: 'AccountingType', dataField: 'Product.AccountingType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
                 { text: 'Quantity',columngroup: 'ProductDetails', dataField: 'Quantity', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
                 { text: 'SettleCurrency', cellsAlign: 'center', align: 'center', dataField: 'SettleCurrency', width: '20%' }
               ]
               
           });  
           
        // create jqxDataTable for Position by Account Type.
           $("#positioncounter2").jqxGrid(
           {
               source: dataAdapter,
               altRows: true,
               width: '99%',
               height: '600',
               sortable: true,
               pageable:false,
               filterable: true,
               groupable: true,
               showstatusbar: true,
               statusbarheight: 50,
               showaggregates: true,
               columnsresize: true,
               columnsreorder: true,

               
               columns: [
                 { text: 'Product', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Product.Description',/* pinned: true,*/  width: '20%' },
                 { text: 'Counterparty', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'PartyId', width: '20%' },
                 { text: 'AccountingType', dataField: 'Product.AccountingType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
                 { text: 'Quantity',columngroup: 'ProductDetails', dataField: 'Quantity', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
                 { text: 'SettleCurrency', cellsAlign: 'center', align: 'center', dataField: 'SettleCurrency', width: '20%' }
               ]
               
           });  
        
        // create jqxDataTable for Position by Currency.
           $("#positioncounter3").jqxGrid(
           {
               source: dataAdapter,
               altRows: true,
               width: '99%',
               height: '600',
               sortable: true,
               pageable:false,
               filterable: true,
               groupable: true,
               showstatusbar: true,
               statusbarheight: 50,
               showaggregates: true,
               columnsresize: true,
               columnsreorder: true,

               
               columns: [
                 { text: 'Product', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Product.Description',/* pinned: true,*/  width: '20%' },
                 { text: 'Counterparty', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'PartyId', width: '20%' },
                 { text: 'AccountingType', dataField: 'Product.AccountingType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
                 { text: 'Quantity',columngroup: 'ProductDetails', dataField: 'Quantity', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
                 { text: 'SettleCurrency', cellsAlign: 'center', align: 'center', dataField: 'SettleCurrency', width: '20%' }
               ]
               
           });  
   

// Master Aggrement Final Grid

var source =
{
dataType: "json",
dataFields: [
	{ name: 'entityId', type: 'string' },
	{ name: 'valuationMarketPlace', type: 'string' },
	{ name: 'agreementType', type: 'string' },
	{ name: 'id', type: 'string' },
	{ name: 'partyId', type: 'string' },
	{ name: 'signedDate', type: 'string' }

], 
url: ezopsContextPath+'/getReports/getmasteraggrementfinalgrid'
};
var dataAdapter = new $.jqx.dataAdapter(source, {
loadComplete: function () {
 //console.log(dataAdapter);
}
});
var cellClass = function (row, dataField, cellText, rowData) {
var cellValue = rowData[dataField];
switch (dataField) {
 case "diffQuantity":
     if (cellValue >100 || cellValue < 0) {
         return "minavg";                            
     }
     if (cellValue <= 100 ) {
         return "max";
     }                       
     return "max";
     
 case "diffMarketValue":
     if (cellValue >100 || cellValue < 0) {
         return "minavg";                            
     }
     if (cellValue <= 100 ) {
         return "max";
     }                        
     return "min";                    
}
};
	
 $("#masterAggrementFinal").jqxGrid(
 {
     source: dataAdapter,
     altRows: true,
     width: '99%',
     height: '600',
     sortable: true,
     pageable:false,
     filterable: true,
     groupable: true,
     showstatusbar: true,
     statusbarheight: 50,
     showaggregates: true,
     columnsresize: true,
     columnsreorder: true,

     
     columns: [
		{text:'EntityId',dataField:'entityId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
		{text:'Valuation Market Place',dataField:'valuationMarketPlace',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
		{text:'Agreement Type',dataField:'agreementType',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
		{text:'Id',dataField:'id',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
		{text:'PartyId',dataField:'partyId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
		{text:'Signed Date',dataField:'signedDate',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'}
     ]
     
 });  
 
/* Chart data for Master Agreement Report */
 var masterAgreementJsonBarSeriesData = new Array();
 var masterAgreementJsonBarCategories = new Array();
 var masterAgreementJson = new Array();

 $("#MasterAgreementReportRefresh").on('click', function(element){
		insertDataReloadDiv(element.currentTarget);
		//$('.loaddiv').show();
	 masterAgreementJson = [];
	 masterAgreementJsonBarSeriesData = [];
	 masterAgreementJsonBarCategories = [];
		$.getJSON(
				ezopsContextPath
						+ '/getReports/getmasteragreemengpiechart?refresh=true',
				function(data) {
					console.log('productByCpJson---'+productByCpJson);
					for ( var i = 0, len = data.length; i < len; i++) {
						masterAgreementJsonBarCategories.push([data[i].partyId]);
						masterAgreementJsonBarSeriesData.push([parseInt(data[i].agreementTypeCount)]);
						masterAgreementJson.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
					}
					getMasterAggrementReport(masterAgreementJson);
					$('.loaddiv').hide();
				});
 });
 $.getJSON(
			ezopsContextPath
					+ '/getReports/getmasteragreemengpiechart',
			function(data) {
				for ( var i = 0, len = data.length; i < len; i++) {
					masterAgreementJsonBarCategories.push([data[i].partyId]);
					masterAgreementJsonBarSeriesData.push([parseInt(data[i].agreementTypeCount)]);
					masterAgreementJson.push([ data[i].partyId,parseInt(data[i].agreementTypeCount) ]);
				}
				getMasterAggrementReport(masterAgreementJson);
				$('.loaddiv').hide();
			});
 var masterReportChecked =  'true';
 $('#master-chart-view1').on('click', function(event) {
 	if(masterReportChecked){
     	$('#MasterAgreementReportChart')
     	.highcharts(
     			{
     				chart : {
     					type : 'bar'
     				},

     				title : {
     					text : ''
     				},
     				subtitle : {
     					text : ''
     				},

     				xAxis : {
     					categories : cashUpcomingBarCategories
     				},
     				credits : {
     					enabled : false
     				},
     				series : [ {
     					name : 'Cash Amount',
     					data : cashUpcomingBarSeriesData

     				} ]
     			});
     	masterReportChecked = 'false';
     }
 	else{
 		masterReportChecked = 'true';
 		getMasterAggrementReport(masterAgreementJson);
 	}

 });
 function getMasterAggrementReport(masterAgreementJson) {
		// Build the chart4
		console.log('processed_json');
		//console.log(masterAgreementJson);
		$('#MasterAgreementReportChart')
		.highcharts(
				{
					chart : {
						plotBackgroundColor : null,
						plotBorderWidth : null,
						plotShadow : false
					},
					title : {
						text : ''
					},
					/* tooltip : {
						pointFormat : 'Quantity: <b>{point.percentage:.1f}%</b>'
					}, */
					plotOptions : {
						pie : {
							allowPointSelect : true,
							cursor : 'pointer',
							dataLabels : {
								enabled : false
							},
							showInLegend : true
						}
					},
					series : [ {
						type : 'pie',
						name : '',
						data : masterAgreementJson
					} ]
				});

	}	    

/* Cash Balance Chart grid source*/

var source =
{
dataType: "json",
dataFields: [
{ name: 'valueDate', type: 'string' },
{ name: 'bookId', type: 'string' },
{ name: 'tradeId', type: 'string' },
{ name: 'cashCurrency', type: 'string' },
{ name: 'productDescription', type: 'string' },
{ name: 'status', type: 'string' },
{ name: 'cashAmount', type: 'string' },
{ name: 'realSettlementDate', type: 'string' },
{ name: 'cashPayReceive', type: 'string' },
{ name: 'securityAmount', type: 'string' },
{ name: 'securityPayReceive', type: 'string' },
{ name: 'underlyingProductDescription', type: 'string' },
{ name: 'paymentCategory', type: 'string' },
{ name: 'productGroup', type: 'string' },
{ name: 'action', type: 'string' },
{ name: 'paymentComment', type: 'string' },
{ name: 'matchingDescription', type: 'string' },
{ name: 'entityCashInstructionSSI', type: 'string' },
{ name: 'partyCashInstructionSSI', type: 'string' },
{ name: 'entitySecurityInstructionSSI', type: 'string' },
{ name: 'partySecurityInstructionSSI', type: 'string' },
{ name: 'id', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'quantity', type: 'string' },
{ name: 'securityUnit', type: 'string' },
{ name: 'securityId', type: 'string' },
{ name: 'deliveryMethod', type: 'string' },
{ name: 'sourceEventId', type: 'string' },
{ name: 'nettingType', type: 'string' },
{ name: 'nettingId', type: 'string' },
{ name: 'bookingDate', type: 'string' },
{ name: 'partyId', type: 'string' },
{ name: 'gLAccount', type: 'string' },
{ name: 'parentPaymentId', type: 'string' },
{ name: 'reversePaymentId', type: 'string' },
{ name: 'settlementMethod', type: 'string' },
{ name: 'knownDate', type: 'string' },
{ name: 'partyInstructionStatus', type: 'string' },
{ name: 'entityInstructionStatus', type: 'string' },
{ name: 'isCashOnly', type: 'string' },
{ name: 'isSecurityOnly', type: 'string' },
{ name: 'clearerId', type: 'string' },
{ name: 'securityGLAccount', type: 'string' },
{ name: 'securitGLAccountName', type: 'string' },
{ name: 'clearerPartyId', type: 'string' },
{ name: 'entityAgentPartyId', type: 'string' },
{ name: 'entityPartyId', type: 'string' },
{ name: 'paymentType', type: 'string' },
{ name: 'settledCashAmount', type: 'string' },
{ name: 'settledSecurityQuantity', type: 'string' },
{ name: 'updateTime', type: 'string' },
{ name: 'matchingType', type: 'string' },
{ name: 'importRef', type: 'string' },
{ name: 'isInternal', type: 'string' },
{ name: 'underlyingProcessingType', type: 'string' },
{ name: 'parentClearerId', type: 'string' }
], 
url: ezopsContextPath+'/getReports/getcashbalancesgrid'
};
var dataAdapter = new $.jqx.dataAdapter(source, {
loadComplete: function () {
// data is loaded.
}
});
var cellClass = function (row, dataField, cellText, rowData) {
var cellValue = rowData[dataField];
switch (dataField) {
case "diffQuantity":
 if (cellValue >100 || cellValue < 0) {
     return "minavg";                            
 }
 if (cellValue <= 100 ) {
     return "max";
 }                       
 return "max";
 
case "diffMarketValue":
 if (cellValue >100 || cellValue < 0) {
     return "minavg";                            
 }
 if (cellValue <= 100 ) {
     return "max";
 }                        
 return "min";                    
}
};
$("#CashBalances").jqxGrid(
	    {
	        source: dataAdapter,
	        altRows: true,
         width: '99%',
         height: '600',
         sortable: true,
         pageable:false,
         filterable: true,
         groupable: true,
         showstatusbar: true,
         statusbarheight: 50,
         showaggregates: true,
         columnsresize: true,
         columnsreorder: true,

	        
	        columns: [
	          	 { text: 'Value Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'valueDate', width: '100px'},
	             { text: 'Book Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookId', width: '100px'},
	             { text: 'Trade Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'tradeId', width: '100px'},
	             { text: 'Cash Currency', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashCurrency', width: '100px'},
	             { text: 'Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productDescription', width: '100px'},
	             { text: 'Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'status', width: '100px'},
	             { text: 'Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashAmount', width: '100px'},
	             { text: 'Real Settlement Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'realSettlementDate', width: '100px'},
	             { text: 'Cash Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashPayReceive', width: '100px'},
	             { text: 'Security Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityAmount', width: '100px'},
	             { text: 'Security Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityPayReceive', width: '100px'},
	             { text: 'Underlying Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProductDescription', width: '100px'},
	             { text: 'Payment Category', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentCategory', width: '100px'},
	             { text: 'Product Group', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productGroup', width: '100px'},
	             { text: 'Action', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'action', width: '100px'},
	             { text: 'Payment Comment', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentComment', width: '100px'},
	             { text: 'Matching Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingDescription', width: '100px'},
	             { text: 'Entity Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityCashInstructionSSI', width: '100px'},
	             { text: 'Party Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyCashInstructionSSI', width: '100px'},
	             { text: 'Entity Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entitySecurityInstructionSSI', width: '100px'},
	             { text: 'Party Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partySecurityInstructionSSI', width: '100px'},
	             { text: 'Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'id', width: '100px'},
	             { text: 'Version', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'version', width: '100px'},
	             { text: 'Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'quantity', width: '100px'},
	             { text: 'Security Unit', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityUnit', width: '100px'},
	             { text: 'Security Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityId', width: '100px'},
	             { text: 'Delivery Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'deliveryMethod', width: '100px'},
	             { text: 'Source Event Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'sourceEventId', width: '100px'},
	             { text: 'Netting Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingType', width: '100px'},
	             { text: 'Netting Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingId', width: '100px'},
	             { text: 'Booking Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookingDate', width: '100px'},
	             { text: 'Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyId', width: '100px'},
	             { text: 'GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'gLAccount', width: '100px'},
	             { text: 'Parent Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentPaymentId', width: '100px'},
	             { text: 'Reverse Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'reversePaymentId', width: '100px'},
	             { text: 'Settlement Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settlementMethod', width: '100px'},
	             { text: 'Known Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'knownDate', width: '100px'},
	             { text: 'Party Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyInstructionStatus', width: '100px'},
	             { text: 'Entity Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityInstructionStatus', width: '100px'},
	             { text: 'Is Cash Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isCashOnly', width: '100px'},
	             { text: 'Is Security Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isSecurityOnly', width: '100px'},
	             { text: 'Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerId', width: '100px'},
	             { text: 'Security GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityGLAccount', width: '100px'},
	             { text: 'Security GL Account Name', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securitGLAccountName', width: '100px'},
	             { text: 'Clearer Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerPartyId', width: '100px'},
	             { text: 'Entity Agent Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityAgentPartyId'},
	             { text: 'Entity Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityPartyId', width: '100px'},
	             { text: 'Payment Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentType', width: '100px'},
	             { text: 'Settled Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledCashAmount', width: '100px'},
	             { text: 'Settled Security Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledSecurityQuantity', width: '100px'},
	             { text: 'Update Time', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'updateTime', width: '100px'},
	             { text: 'Matching Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingType', width: '100px'},
	             { text: 'Import Ref', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'importRef', width: '100px'},
	             { text: 'Is Internal', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isInternal', width: '100px'},
	             { text: 'Underlying Processing Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProcessingType', width: '100px'},
	             { text: 'Parent Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentClearerId', width: '100px'}
	        ]
	    }); 

/* Cash Upcoming Pay Receive Grid data */
var cashUpcomingSource =
{
dataType: "json",
dataFields: [
{ name: 'valueDate', type: 'string' },
{ name: 'bookId', type: 'string' },
{ name: 'tradeId', type: 'string' },
{ name: 'cashCurrency', type: 'string' },
{ name: 'productDescription', type: 'string' },
{ name: 'status', type: 'string' },
{ name: 'cashAmount', type: 'string' },
{ name: 'realSettlementDate', type: 'string' },
{ name: 'cashPayReceive', type: 'string' },
{ name: 'securityAmount', type: 'string' },
{ name: 'securityPayReceive', type: 'string' },
{ name: 'underlyingProductDescription', type: 'string' },
{ name: 'paymentCategory', type: 'string' },
{ name: 'productGroup', type: 'string' },
{ name: 'action', type: 'string' },
{ name: 'paymentComment', type: 'string' },
{ name: 'matchingDescription', type: 'string' },
{ name: 'entityCashInstructionSSI', type: 'string' },
{ name: 'partyCashInstructionSSI', type: 'string' },
{ name: 'entitySecurityInstructionSSI', type: 'string' },
{ name: 'partySecurityInstructionSSI', type: 'string' },
{ name: 'id', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'quantity', type: 'string' },
{ name: 'securityUnit', type: 'string' },
{ name: 'securityId', type: 'string' },
{ name: 'deliveryMethod', type: 'string' },
{ name: 'sourceEventId', type: 'string' },
{ name: 'nettingType', type: 'string' },
{ name: 'nettingId', type: 'string' },
{ name: 'bookingDate', type: 'string' },
{ name: 'partyId', type: 'string' },
{ name: 'gLAccount', type: 'string' },
{ name: 'parentPaymentId', type: 'string' },
{ name: 'reversePaymentId', type: 'string' },
{ name: 'settlementMethod', type: 'string' },
{ name: 'knownDate', type: 'string' },
{ name: 'partyInstructionStatus', type: 'string' },
{ name: 'entityInstructionStatus', type: 'string' },
{ name: 'isCashOnly', type: 'string' },
{ name: 'isSecurityOnly', type: 'string' },
{ name: 'clearerId', type: 'string' },
{ name: 'securityGLAccount', type: 'string' },
{ name: 'securitGLAccountName', type: 'string' },
{ name: 'clearerPartyId', type: 'string' },
{ name: 'entityAgentPartyId', type: 'string' },
{ name: 'entityPartyId', type: 'string' },
{ name: 'paymentType', type: 'string' },
{ name: 'settledCashAmount', type: 'string' },
{ name: 'settledSecurityQuantity', type: 'string' },
{ name: 'updateTime', type: 'string' },
{ name: 'matchingType', type: 'string' },
{ name: 'importRef', type: 'string' },
{ name: 'isInternal', type: 'string' },
{ name: 'underlyingProcessingType', type: 'string' },
{ name: 'parentClearerId', type: 'string' }
], 
url: ezopsContextPath+'/getReports/getcashupcomingpayreceivegrid'
};
var dataAdapter = new $.jqx.dataAdapter(cashUpcomingSource, {
loadComplete: function () {
// data is loaded.
}
});
var cellClass = function (row, dataField, cellText, rowData) {
var cellValue = rowData[dataField];
switch (dataField) {
case "diffQuantity":
 if (cellValue >100 || cellValue < 0) {
     return "minavg";                            
 }
 if (cellValue <= 100 ) {
     return "max";
 }                       
 return "max";
 
case "diffMarketValue":
 if (cellValue >100 || cellValue < 0) {
     return "minavg";                            
 }
 if (cellValue <= 100 ) {
     return "max";
 }                        
 return "min";                    
}
};
$("#CashUpcomingGrid").jqxGrid(
	    {
	        source: dataAdapter,
	        altRows: true,
         width: '99%',
         height: '600',
         sortable: true,
         pageable:false,
         filterable: true,
         groupable: true,
         showstatusbar: true,
         statusbarheight: 50,
         showaggregates: true,
         columnsresize: true,
         columnsreorder: true,

	        
	        columns: [
	          	 { text: 'Value Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'valueDate', width: '100px'},
	             { text: 'Book Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookId', width: '100px'},
	             { text: 'Trade Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'tradeId', width: '100px'},
	             { text: 'Cash Currency', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashCurrency', width: '100px'},
	             { text: 'Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productDescription', width: '100px'},
	             { text: 'Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'status', width: '100px'},
	             { text: 'Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashAmount', width: '100px'},
	             { text: 'Real Settlement Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'realSettlementDate', width: '100px'},
	             { text: 'Cash Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashPayReceive', width: '100px'},
	             { text: 'Security Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityAmount', width: '100px'},
	             { text: 'Security Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityPayReceive', width: '100px'},
	             { text: 'Underlying Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProductDescription', width: '100px'},
	             { text: 'Payment Category', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentCategory', width: '100px'},
	             { text: 'Product Group', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productGroup', width: '100px'},
	             { text: 'Action', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'action', width: '100px'},
	             { text: 'Payment Comment', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentComment', width: '100px'},
	             { text: 'Matching Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingDescription', width: '100px'},
	             { text: 'Entity Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityCashInstructionSSI', width: '100px'},
	             { text: 'Party Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyCashInstructionSSI', width: '100px'},
	             { text: 'Entity Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entitySecurityInstructionSSI', width: '100px'},
	             { text: 'Party Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partySecurityInstructionSSI', width: '100px'},
	             { text: 'Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'id', width: '100px'},
	             { text: 'Version', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'version', width: '100px'},
	             { text: 'Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'quantity', width: '100px'},
	             { text: 'Security Unit', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityUnit', width: '100px'},
	             { text: 'Security Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityId', width: '100px'},
	             { text: 'Delivery Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'deliveryMethod', width: '100px'},
	             { text: 'Source Event Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'sourceEventId', width: '100px'},
	             { text: 'Netting Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingType', width: '100px'},
	             { text: 'Netting Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingId', width: '100px'},
	             { text: 'Booking Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookingDate', width: '100px'},
	             { text: 'Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyId', width: '100px'},
	             { text: 'GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'gLAccount', width: '100px'},
	             { text: 'Parent Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentPaymentId', width: '100px'},
	             { text: 'Reverse Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'reversePaymentId', width: '100px'},
	             { text: 'Settlement Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settlementMethod', width: '100px'},
	             { text: 'Known Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'knownDate', width: '100px'},
	             { text: 'Party Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyInstructionStatus', width: '100px'},
	             { text: 'Entity Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityInstructionStatus', width: '100px'},
	             { text: 'Is Cash Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isCashOnly', width: '100px'},
	             { text: 'Is Security Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isSecurityOnly', width: '100px'},
	             { text: 'Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerId', width: '100px'},
	             { text: 'Security GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityGLAccount', width: '100px'},
	             { text: 'Security GL Account Name', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securitGLAccountName', width: '100px'},
	             { text: 'Clearer Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerPartyId', width: '100px'},
	             { text: 'Entity Agent Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityAgentPartyId'},
	             { text: 'Entity Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityPartyId', width: '100px'},
	             { text: 'Payment Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentType', width: '100px'},
	             { text: 'Settled Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledCashAmount', width: '100px'},
	             { text: 'Settled Security Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledSecurityQuantity', width: '100px'},
	             { text: 'Update Time', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'updateTime', width: '100px'},
	             { text: 'Matching Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingType', width: '100px'},
	             { text: 'Import Ref', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'importRef', width: '100px'},
	             { text: 'Is Internal', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isInternal', width: '100px'},
	             { text: 'Underlying Processing Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProcessingType', width: '100px'},
	             { text: 'Parent Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentClearerId', width: '100px'}
	        ]
});
/**  Risk Cash Flow **/
    
    // prepare the data
    var source =
    {
        dataType: "json",
        dataFields: [
			{ name: 'date', type: 'string' },
			{ name: 'amount', type: 'string' },
			{ name: 'flowType', type: 'string' },
			{ name: 'notional', type: 'string' },
			{ name: 'tradeId', type: 'string' },
			{ name: 'version', type: 'string' },
			{ name: 'bookId', type: 'string' },
			{ name: 'folderId', type: 'string' },
			{ name: 'partyId', type: 'string' },
			{ name: 'traderId', type: 'string' },
			{ name: 'productType', type: 'string' },
			{ name: 'description', type: 'string' },
			{ name: 'status', type: 'string' },
			{ name: 'currency', type: 'string' },
			{ name: 'underlierInfo', type: 'string' },
			{ name: 'maturityDate', type: 'string' },
			{ name: 'maturityDateYear', type: 'string' },
			{ name: 'changedCount', type: 'string' },
			{ name: 'book', type: 'string' },
			{ name: 'folder', type: 'string' },
			{ name: 'party', type: 'string' },
			{ name: 'entity', type: 'string' },
			{ name: 'trader', type: 'string' },
			{ name: 'flowDate', type: 'string' },
			{ name: 'feeType', type: 'string' },
			{ name: 'legId', type: 'string' },
			{ name: 'legType', type: 'string' },
			{ name: 'currentNotional', type: 'string' },
			{ name: 'nDays', type: 'string' },
			{ name: 'fxRate', type: 'string' },
			{ name: 'fxPv', type: 'string' },
			{ name: 'cumulativeAmount', type: 'string' },
			{ name: 'bActivity', type: 'string' },
			{ name: 'bAdminStrategy', type: 'string' },
			{ name: 'bCalendar', type: 'string' },
			{ name: 'bDesk', type: 'string' },
			{ name: 'bFund', type: 'string' },
			{ name: 'bGeography', type: 'string' },
			{ name: 'bLegalEntity', type: 'string' },
			{ name: 'bRecapGroup', type: 'string' },
			{ name: 'bSimulation', type: 'string' },
			{ name: 'bStrategy', type: 'string' },
			{ name: 'bStrategyName', type: 'string' },
			{ name: 'bStrategyType', type: 'string' },
			{ name: 'bSubActivity', type: 'string' }

        ], 
        url:  ezopsContextPath+'/getReports/getriskcashflowgrid'
    };
    var dataAdapter = new $.jqx.dataAdapter(source, {
        loadComplete: function () {
            // data is loaded.
        }
    });
    var cellClass = function (row, dataField, cellText, rowData) {
        var cellValue = rowData[dataField];
        switch (dataField) {
            case "diffQuantity":
                if (cellValue >100 || cellValue < 0) {
                    return "minavg";                            
                }
                if (cellValue <= 100 ) {
                    return "max";
                }                       
                return "max";
                
            case "diffMarketValue":
                if (cellValue >100 || cellValue < 0) {
                    return "minavg";                            
                }
                if (cellValue <= 100 ) {
                    return "max";
                }                        
                return "min";                    
        }
    }
    // create jqxDataTable.
    $("#riskCashFlowGrid").jqxGrid(
    {
        source: dataAdapter,
        altRows: true,
        width: '99%',
        height: '600',
        sortable: true,
        pageable:false,
        filterable: true,
        groupable: true,
        showstatusbar: true,
        statusbarheight: 50,
        showaggregates: true,
        columnsresize: true,
        columnsreorder: true,
        
        columns: [
			{text:'Date',dataField:'date',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Amount',dataField:'amount',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Flow Type',dataField:'flowType',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Notional',dataField:'notional',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Trade Id',dataField:'tradeId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Version',dataField:'version',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Book Id',dataField:'bookId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Folder Id',dataField:'folderId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Party Id',dataField:'partyId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Trader Id',dataField:'traderId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Product Type',dataField:'productType',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Description',dataField:'description',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Status',dataField:'status',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Currency',dataField:'currency',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Underlier Info',dataField:'underlierInfo',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Maturity Date',dataField:'maturityDate',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Maturity Date Year',dataField:'maturityDateYear',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Changed Count',dataField:'changedCount',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Book',dataField:'book',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Folder',dataField:'folder',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Party',dataField:'party',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Entity',dataField:'entity',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Trader',dataField:'trader',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Flow Date',dataField:'flowDate',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Fee Type',dataField:'feeType',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Leg Id',dataField:'legId',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Leg Type',dataField:'legType',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Current Notional',dataField:'currentNotional',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'NDays',dataField:'nDays',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Fx Rate',dataField:'fxRate',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Fx Pv',dataField:'fxPv',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'Cumulative Amount',dataField:'cumulativeAmount',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:Activity',dataField:'bActivity',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:AdminStrategy',dataField:'bAdminStrategy',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:Calendar',dataField:'bCalendar',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:Desk',dataField:'bDesk',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:Fund',dataField:'bFund',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:Geography',dataField:'bGeography',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:LegalEntity',dataField:'bLegalEntity',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:RecapGroup',dataField:'bRecapGroup',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:Simulation',dataField:'bSimulation',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:Strategy',dataField:'bStrategy',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:StrategyName',dataField:'bStrategyName',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:StrategyType',dataField:'bStrategyType',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'},
			{text:'B:SubActivity',dataField:'bSubActivity',cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center',  width: '100px'}
        ]
        
    });  

/* Cash Balance Chart grid source*/
var CashDailyChangeSource =
{
dataType: "json",
dataFields: [
  { name: 'valueDate', type: 'string' },
  { name: 'bookId', type: 'string' },
  { name: 'tradeId', type: 'string' },
  { name: 'cashCurrency', type: 'string' },
  { name: 'productDescription', type: 'string' },
  { name: 'status', type: 'string' },
  { name: 'cashAmount', type: 'string' },
  { name: 'realSettlementDate', type: 'string' },
  { name: 'cashPayReceive', type: 'string' },
  { name: 'securityAmount', type: 'string' },
  { name: 'securityPayReceive', type: 'string' },
  { name: 'underlyingProductDescription', type: 'string' },
  { name: 'paymentCategory', type: 'string' },
  { name: 'productGroup', type: 'string' },
  { name: 'action', type: 'string' },
  { name: 'paymentComment', type: 'string' },
  { name: 'matchingDescription', type: 'string' },
  { name: 'entityCashInstructionSSI', type: 'string' },
  { name: 'partyCashInstructionSSI', type: 'string' },
  { name: 'entitySecurityInstructionSSI', type: 'string' },
  { name: 'partySecurityInstructionSSI', type: 'string' },
  { name: 'id', type: 'string' },
  { name: 'version', type: 'string' },
  { name: 'quantity', type: 'string' },
  { name: 'securityUnit', type: 'string' },
  { name: 'securityId', type: 'string' },
  { name: 'deliveryMethod', type: 'string' },
  { name: 'sourceEventId', type: 'string' },
  { name: 'nettingType', type: 'string' },
  { name: 'nettingId', type: 'string' },
  { name: 'bookingDate', type: 'string' },
  { name: 'partyId', type: 'string' },
  { name: 'gLAccount', type: 'string' },
  { name: 'parentPaymentId', type: 'string' },
  { name: 'reversePaymentId', type: 'string' },
  { name: 'settlementMethod', type: 'string' },
  { name: 'knownDate', type: 'string' },
  { name: 'partyInstructionStatus', type: 'string' },
  { name: 'entityInstructionStatus', type: 'string' },
  { name: 'isCashOnly', type: 'string' },
  { name: 'isSecurityOnly', type: 'string' },
  { name: 'clearerId', type: 'string' },
  { name: 'securityGLAccount', type: 'string' },
  { name: 'securitGLAccountName', type: 'string' },
  { name: 'clearerPartyId', type: 'string' },
  { name: 'entityAgentPartyId', type: 'string' },
  { name: 'entityPartyId', type: 'string' },
  { name: 'paymentType', type: 'string' },
  { name: 'settledCashAmount', type: 'string' },
  { name: 'settledSecurityQuantity', type: 'string' },
  { name: 'updateTime', type: 'string' },
  { name: 'matchingType', type: 'string' },
  { name: 'importRef', type: 'string' },
  { name: 'isInternal', type: 'string' },
  { name: 'underlyingProcessingType', type: 'string' },
  { name: 'parentClearerId', type: 'string' }
], 
url: ezopsContextPath+'/getReports/getcashdailychangegrid'
};
var dataAdapter = new $.jqx.dataAdapter(CashDailyChangeSource, {
loadComplete: function () {
 // data is loaded.
}
});
var cellClass = function (row, dataField, cellText, rowData) {
var cellValue = rowData[dataField];
switch (dataField) {
 case "diffQuantity":
     if (cellValue >100 || cellValue < 0) {
         return "minavg";                            
     }
     if (cellValue <= 100 ) {
         return "max";
     }                       
     return "max";
     
 case "diffMarketValue":
     if (cellValue >100 || cellValue < 0) {
         return "minavg";                            
     }
     if (cellValue <= 100 ) {
         return "max";
     }                        
     return "min";                    
}
};
 $("#CashDailyChange").jqxGrid(
 	    {
 	        source: dataAdapter,
 	        altRows: true,
             width: '99%',
             height: '600',
             sortable: true,
             pageable:false,
             filterable: true,
             groupable: true,
             showstatusbar: true,
             statusbarheight: 50,
             showaggregates: true,
             columnsresize: true,
             columnsreorder: true,

 	        
 	        columns: [
 	          	 { text: 'Value Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'valueDate', width: '100px'},
 	             { text: 'Book Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookId', width: '100px'},
 	             { text: 'Trade Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'tradeId', width: '100px'},
 	             { text: 'Cash Currency', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashCurrency', width: '100px'},
 	             { text: 'Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productDescription', width: '100px'},
 	             { text: 'Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'status', width: '100px'},
 	             { text: 'Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashAmount', width: '100px'},
 	             { text: 'Real Settlement Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'realSettlementDate', width: '100px'},
 	             { text: 'Cash Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashPayReceive', width: '100px'},
 	             { text: 'Security Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityAmount', width: '100px'},
 	             { text: 'Security Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityPayReceive', width: '100px'},
 	             { text: 'Underlying Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProductDescription', width: '100px'},
 	             { text: 'Payment Category', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentCategory', width: '100px'},
 	             { text: 'Product Group', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productGroup', width: '100px'},
 	             { text: 'Action', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'action', width: '100px'},
 	             { text: 'Payment Comment', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentComment', width: '100px'},
 	             { text: 'Matching Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingDescription', width: '100px'},
 	             { text: 'Entity Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityCashInstructionSSI', width: '100px'},
 	             { text: 'Party Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyCashInstructionSSI', width: '100px'},
 	             { text: 'Entity Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entitySecurityInstructionSSI', width: '100px'},
 	             { text: 'Party Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partySecurityInstructionSSI', width: '100px'},
 	             { text: 'Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'id', width: '100px'},
 	             { text: 'Version', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'version', width: '100px'},
 	             { text: 'Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'quantity', width: '100px'},
 	             { text: 'Security Unit', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityUnit', width: '100px'},
 	             { text: 'Security Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityId', width: '100px'},
 	             { text: 'Delivery Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'deliveryMethod', width: '100px'},
 	             { text: 'Source Event Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'sourceEventId', width: '100px'},
 	             { text: 'Netting Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingType', width: '100px'},
 	             { text: 'Netting Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingId', width: '100px'},
 	             { text: 'Booking Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookingDate', width: '100px'},
 	             { text: 'Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyId', width: '100px'},
 	             { text: 'GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'gLAccount', width: '100px'},
 	             { text: 'Parent Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentPaymentId', width: '100px'},
 	             { text: 'Reverse Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'reversePaymentId', width: '100px'},
 	             { text: 'Settlement Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settlementMethod', width: '100px'},
 	             { text: 'Known Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'knownDate', width: '100px'},
 	             { text: 'Party Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyInstructionStatus', width: '100px'},
 	             { text: 'Entity Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityInstructionStatus', width: '100px'},
 	             { text: 'Is Cash Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isCashOnly', width: '100px'},
 	             { text: 'Is Security Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isSecurityOnly', width: '100px'},
 	             { text: 'Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerId', width: '100px'},
 	             { text: 'Security GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityGLAccount', width: '100px'},
 	             { text: 'Security GL Account Name', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securitGLAccountName', width: '100px'},
 	             { text: 'Clearer Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerPartyId', width: '100px'},
 	             { text: 'Entity Agent Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityAgentPartyId'},
 	             { text: 'Entity Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityPartyId', width: '100px'},
 	             { text: 'Payment Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentType', width: '100px'},
 	             { text: 'Settled Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledCashAmount', width: '100px'},
 	             { text: 'Settled Security Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledSecurityQuantity', width: '100px'},
 	             { text: 'Update Time', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'updateTime', width: '100px'},
 	             { text: 'Matching Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingType', width: '100px'},
 	             { text: 'Import Ref', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'importRef', width: '100px'},
 	             { text: 'Is Internal', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isInternal', width: '100px'},
 	             { text: 'Underlying Processing Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProcessingType', width: '100px'},
 	             { text: 'Parent Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentClearerId', width: '100px'}
 	        ]
 	    }); 


/**  Static Charts -- Start **/

        
	//to disbale footer links--------------------------
	$("a.disabled").click(function () {return false;});
    	
        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'ezId', type: 'string' },
                 { name: 'cp', type: 'string' },
                 { name: 'secType', type: 'string' },
                 { name: 'cpId', type: 'string' },
                 { name: 'underlier', type: 'string' }
            ], 
            url: 'assets/sampledata/Aging-Report.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        }
        // create jqxDataTable.
        $("#AgingReportGrid").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showstatusbar: true,
            statusbarheight: 50,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,

            
            columns: [
              { text: 'Investment ID', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'ezId',/* pinned: true,*/  width: '20%' },
              { text: 'Counterparty', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cp', width: '20%' },
              { text: 'Sec Type', dataField: 'secType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
              { text: 'Trade Date',columngroup: 'ProductDetails', dataField: 'cpId', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
              { text: 'Confirmed: Y/N', cellsAlign: 'center', align: 'center', dataField: 'underlier', width: '20%',
                  aggregates: ['count'
                  ]}
            ]
            
        });  
    });

        $(document).ready(function () {          
            // prepare the data
            
            var source =
            {
                dataType: "csv",
                dataFields: [
                    { name: 'TaskID', type: 'number' },
                    { name: 'ParentTaskID', type: 'number' },
                    { name: 'TaskName', type: 'string' },
                    { name: 'Signoff_Type', type: 'string' },
                    { name: 'STATUS_OF_FILES', type: 'string' },
                    { name: 'Task_User', type: 'string' },
                    { name: 'COMMENT', type: 'string' },
                    { name: 'DATA_AVAILABILITY', type: 'string' },
                    { name: 'Ezopsuseremail', type: 'string' },
                    { name: 'COMPLETION', type: 'string' },
                    { name: 'UserEmail_ID', type: 'string' },
                    { name: 'UserEmail', type: 'string' }
                ],
                hierarchy:
                {
                    keyDataField: { name: 'TaskID' },
                    parentDataField: { name: 'ParentTaskID' }
                },
                id: 'TaskID',
                url: 'assets/sampledata/Positionsrecon.csv'
            };
            var dataAdapter = new $.jqx.dataAdapter(source);
            // create Tree Grid
            $("#treeGrid").jqxTreeGrid(
            {
                width: '99%',
                source: dataAdapter,
                pageable: false,
                editable: true,
                columnsResize: true,
                sortable: true,
                filterable: true,
                filterMode: 'advanced',
                ready: function()
                {
                    // expand row with 'EmployeeKey = 2'
                    $("#treeGrid").jqxTreeGrid('expandRow', 0);
                },                    
                
                columns: [
                  /*{ text: 'Client', dataField: 'Client', minWidth: 100, width: '8%' },*/
                  { text: ' ', dataField: 'TaskName', minWidth: 150, width: '20%' },
                  { text: '', dataField: 'Signoff_Type', minWidth: 100, width: '6%' },/**/                      
                  { text: 'EZ ID', dataField: 'STATUS_OF_FILES', minWidth: 110, width: '10%' },
                  { text: 'Street ID', dataField: 'Task_User', cellsFormat: 'd', minWidth: 80, width: '8%' },
                  { text: 'CP', dataField: 'COMMENT', cellsFormat: 'd', minWidth: 150},
                  { text: 'Sec Type', dataField: 'DATA_AVAILABILITY', cellsFormat: 'd', minWidth: 120, width: '8%' },
                  { text: 'Quantity', dataField: 'Ezopsuseremail', cellsFormat: 'd', minWidth: 120, width: '10%' },
                  { text: 'Description', dataField: 'COMPLETION', cellsFormat: 'd', minWidth: 100, width: '10%' },
                  { text: ' Trade Dt', dataField: 'UserEmail_ID', cellsFormat: 'd', minWidth: 150, width: '15%' },
                  { text: ' Maturity Dt', dataField: 'UserEmail', cellsFormat: 'd', minWidth: 150, width: '15%' }
                ]
            });
             
            // prepare the data
            
            var source =
            {
                dataType: "csv",
                dataFields: [
                    { name: 'TaskID', type: 'number' },
                    { name: 'ParentTaskID', type: 'number' },
                    { name: 'TaskName', type: 'string' },
                    { name: 'Signoff_Type', type: 'string' },
                    { name: 'STATUS_OF_FILES', type: 'string' },
                    { name: 'Task_User', type: 'string' },
                    { name: 'COMMENT', type: 'string' },
                    { name: 'DATA_AVAILABILITY', type: 'string' },
                    { name: 'Ezopsuseremail', type: 'string' },
                    { name: 'COMPLETION', type: 'string' },
                    { name: 'UserEmail_ID', type: 'string' },
                    { name: 'UserEmail', type: 'string' }
                ],
                hierarchy:
                {
                    keyDataField: { name: 'TaskID' },
                    parentDataField: { name: 'ParentTaskID' }
                },
                id: 'TaskID',
                url: 'assets/sampledata/cashrecon.csv'
            };
            var dataAdapter = new $.jqx.dataAdapter(source);
            // create Tree Grid
            $("#cashrecon").jqxTreeGrid(
            {
                width: '99%',
                source: dataAdapter,
                pageable: false,
                editable: true,
                columnsResize: true,
                sortable: true,
                filterable: true,
                filterMode: 'advanced',
                                  
                
                columns: [
                  /*{ text: 'Client', dataField: 'Client', minWidth: 100, width: '8%' },*/
                  { text: ' ', dataField: 'TaskName', minWidth: 150, width: '20%' },
                  { text: '', dataField: 'Signoff_Type', minWidth: 100, width: '6%' },/**/                      
                  { text: 'EZ ID', dataField: 'STATUS_OF_FILES', minWidth: 110, width: '10%' },
                  { text: 'Street ID', dataField: 'Task_User', cellsFormat: 'd', minWidth: 80, width: '8%' },
                  { text: 'CP', dataField: 'COMMENT', cellsFormat: 'd', minWidth: 150},
                  { text: 'Sec Type', dataField: 'DATA_AVAILABILITY', cellsFormat: 'd', minWidth: 120, width: '8%' },
                  { text: 'Quantity', dataField: 'Ezopsuseremail', cellsFormat: 'd', minWidth: 120, width: '10%' },
                  { text: 'Description', dataField: 'COMPLETION', cellsFormat: 'd', minWidth: 100, width: '10%' },
                  { text: ' Trade Dt', dataField: 'UserEmail_ID', cellsFormat: 'd', minWidth: 150, width: '15%' },
                  { text: ' Maturity Dt', dataField: 'UserEmail', cellsFormat: 'd', minWidth: 150, width: '15%' }
                ]
            });
             

        
        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'Product.Description', type: 'string' },
                 { name: 'Product.AccountingType', type: 'string' },
                 { name: 'PartyId', type: 'string' },
                 { name: 'SettleCurrency', type: 'string' },
                 { name: 'Quantity', type: 'string' },
                 { name: 'Product.Isin', type: 'string' },
                 { name: 'PositionType', type: 'string' },
                 { name: 'SettleCurrency', type: 'string' }
            ], 
            url: 'assets/sampledata/PositionbyCounterparty.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        };
        // create jqxDataTable.
        /*$("#positioncounter").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showstatusbar: true,
            statusbarheight: 50,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,

            
            columns: [
              { text: 'Product', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Product.Description', pinned: true,  width: '20%' },
              { text: 'Counterparty', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'PartyId', width: '20%' },
              { text: 'AccountingType', dataField: 'Product.AccountingType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
              { text: 'Quantity',columngroup: 'ProductDetails', dataField: 'Quantity', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
              { text: 'SettleCurrency', cellsAlign: 'center', align: 'center', dataField: 'SettleCurrency', width: '20%' }
            ]
        });*/  

        
/*        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'ezId', type: 'string' },
                 { name: 'cp', type: 'string' },
                 { name: 'secType', type: 'string' },
                 { name: 'cpId', type: 'string' },
                 { name: 'underlier', type: 'string' }
            ], 
            url: 'assets/sampledata/PositionbyProduct.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        }
        // create jqxDataTable.
        $("#PositionbyProduct").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showstatusbar: true,
            statusbarheight: 50,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,

            
            columns: [
              { text: 'Investment ID', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'ezId', pinned: true,  width: '20%' },
              { text: 'Counterparty', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cp', width: '20%' },
              { text: 'Sec Type', dataField: 'secType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
              { text: 'Quantity',columngroup: 'ProductDetails', dataField: 'cpId', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
              { text: 'Count', cellsAlign: 'center', align: 'center', dataField: 'underlier', width: '20%' }
            ]
            
        });*/  
        
        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'ezId', type: 'string' },
                 { name: 'cp', type: 'string' },
                 { name: 'secType', type: 'string' },
                 { name: 'cpId', type: 'string' },
                 { name: 'underlier', type: 'string' }
            ], 
            url: 'assets/sampledata/CashPaymentProjections.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        }
        // create jqxDataTable.
        $("#CashPaymentProjections").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showstatusbar: true,
            statusbarheight: 50,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,

            
            columns: [
              { text: 'Notes', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'ezId',/* pinned: true,*/  width: '20%' },
              { text: 'Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cp', width: '20%' },
              { text: 'USD', dataField: 'secType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
              { text: 'EUR',columngroup: 'ProductDetails', dataField: 'cpId', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
              { text: 'JPY', cellsAlign: 'center', align: 'center', dataField: 'underlier', width: '20%' }
            ]
            
        });  
    

        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'ezId', type: 'string' },
                 { name: 'cp', type: 'string' },
                 { name: 'secType', type: 'string' },
                 { name: 'cpId', type: 'string' },
                 { name: 'underlier', type: 'string' }
            ], 
            url: 'assets/sampledata/TradeFailures.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        }
        // create jqxDataTable.
        $("#TradeFailuresGrid").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showstatusbar: true,
            statusbarheight: 50,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,

            
            columns: [
              { text: 'Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'ezId',/* pinned: true,*/  width: '20%' },
              { text: 'GS PB', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cp', width: '20%' },
              { text: 'MS PB', dataField: 'secType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
              { text: 'Client',columngroup: 'ProductDetails', dataField: 'cpId', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
              { text: 'Failure Source', cellsAlign: 'center', align: 'center', dataField: 'underlier', width: '20%' }
            ]
            
        });  
    
        
        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'ezId', type: 'string' },
                 { name: 'cp', type: 'string' },
                 { name: 'secType', type: 'string' },
                 { name: 'cpId', type: 'string' },
                 { name: 'underlier', type: 'string' },
                 { name: 'MV_Diff', type: 'string' }
            ], 
            url: 'assets/sampledata/CollateralOverview.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        }
        // create jqxDataTable.
        $("#CollateralOverview").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,
            columns: [
              { text: 'Counterparty', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'ezId',/* pinned: true,*/  width: '20%' },
              { text: 'Collateral Balance', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cp', width: '20%' },
              { text: 'Todays Collateral Change', dataField: 'secType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '20%' },
              { text: 'CP MV',columngroup: 'ProductDetails', dataField: 'cpId', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '20%' },
              { text: 'EZ MV', cellsAlign: 'center', align: 'center', dataField: 'underlier', width: '20%'},
              { text: 'MV Diff', cellsAlign: 'center', align: 'center', dataField: 'MV_Diff', width: '20%'
                 }
            ]
            
        });  

		
    	// ---------------Dashboard Static charts----------//

    	$(function() {
    		var chart;
    		$(document)
    				.ready(
    						function() {
    							// Build the chart4
    							$('#containerpie2')
    									.highcharts(
    											{
    												chart : {
    													plotBackgroundColor : null,
    													plotBorderWidth : null,
    													plotShadow : false
    												},
    												title : {
    													text : ''
    												},
    												tooltip : {
    													pointFormat : '{series.name}: <b>{point.percentage:.1f}%</b>'
    												},
    												plotOptions : {
    													pie : {
    														allowPointSelect : true,
    														cursor : 'pointer',
    														dataLabels : {
    															enabled : false
    														},
    														showInLegend : true
    													}
    												},
    												series : [ {
    													type : 'pie',
    													name : 'Share',
    													data : [ [ 'JPM', 323 ],
    															[ 'CS', 171 ],
    															[ 'Citi', 4 ],
    															[ 'MS', 23 ],
    															[ 'GS', 5 ]

    													]
    												} ]
    											});
    						});

    	});
    	$(function() {
    		var chart;
    		$(document).ready(function() {
    			// Build the chart4
    			$('#containerpie3').highcharts({
    				chart : {
    					type : 'bar'
    				},
    				title : {
    					text : ''
    				},
    				subtitle : {
    					text : ''
    				},
    				xAxis : {
    					categories : [ 'JPM', 'CS', 'Citi', 'MS', 'GS' ]
    				},
    				credits : {
    					enabled : false
    				},
    				series : [ {
    					name : 'Today Collateral Change',
    					data : [ 11000000, -1000000, 0, 2500000, 450000 ]

    				} ]
    			});
    		});

    	});
    	$(function() {
    		var chart;
    		$(document)
    				.ready(
    						function() {
    							// Build the chart4
    							$('#AgingReportChart')
    									.highcharts(
    											{
    												chart : {
    													plotBackgroundColor : null,
    													plotBorderWidth : null,
    													plotShadow : false
    												},
    												title : {
    													text : ''
    												},
    												tooltip : {
    													pointFormat : '{series.name}: <b>{point.percentage:.1f}%</b>'
    												},
    												plotOptions : {
    													pie : {
    														allowPointSelect : true,
    														cursor : 'pointer',
    														dataLabels : {
    															enabled : false
    														},
    														showInLegend : true
    													}
    												},
    												series : [ {
    													type : 'pie',
    													name : 'Share',
    													data : [
    															[ 'Confirmed  ', 417 ],
    															[ 'UnConfirmed < T+2 ',
    																	50 ],
    															[
    																	'UnConfirmed: 2- 5 days',
    																	45 ],
    															[
    																	'UnConfirmed: 6-30 days',
    																	12 ],
    															[
    																	'UnConfirmed >30 days',
    																	2 ]

    													]
    												} ]
    											});
    						}());

    	});

    	$(function() {
    		$('#containerpie5')
    				.highcharts(
    						{
    							chart : {
    								type : 'column'
    							},
    							title : {
    								text : ''
    							},
    							subtitle : {
    								text : ''
    							},
    							xAxis : {
    								categories : [ '4-Jul', '8-Jul', '11-Jul',
    										'15-Jul', '17-Jul', '24-Jul', '31-Jul' ]
    							},
    							yAxis : {
    								min : 0,
    								title : {
    									text : ''
    								}
    							},
    							tooltip : {
    								headerFormat : '<span style="font-size:10px">{point.key}</span><table>',
    								pointFormat : '<tr><td style="color:{series.color};padding:0">{series.name}: </td>'
    										+ '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
    								footerFormat : '</table>',
    								shared : true,
    								useHTML : true
    							},
    							plotOptions : {
    								column : {
    									pointPadding : 0.2,
    									borderWidth : 0
    								}
    							},
    							series : [
    									{
    										name : 'USD',
    										data : [ 0, 0, 1113454, 0, 433500, 0,
    												213443.3 ]

    									},
    									{
    										name : 'EUR',
    										data : [ 111342.1, 453200, 0, 342452, 0,
    												115634, 453332 ]

    									},
    									{
    										name : 'JPY',
    										data : [ 3938434, 0, 0, 0, 0, 0, 1257426.4 ]

    									} ]
    						});
    	});

    	$(function() {
    		$('#TradeFailuresChart')
    				.highcharts(
    						{
    							chart : {
    								type : 'column'
    							},
    							title : {
    								text : ''
    							},
    							subtitle : {
    								text : ''
    							},
    							xAxis : {
    								categories : [ '6-2-14', '6-3-14', '6-4-14',
    										'6-6-14', '6-9-14' ]
    							},
    							yAxis : {
    								min : 0,
    								title : {
    									text : ''
    								}
    							},
    							tooltip : {
    								headerFormat : '<span style="font-size:10px">{point.key}</span><table>',
    								pointFormat : '<tr><td style="color:{series.color};padding:0">{series.name}: </td>'
    										+ '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
    								footerFormat : '</table>',
    								shared : true,
    								useHTML : true
    							},
    							plotOptions : {
    								column : {
    									pointPadding : 0.2,
    									borderWidth : 0
    								}
    							},
    							series : [ {
    								name : 'GS_PB',
    								data : [ 1, 0, 1, 0, 1 ]

    							}, {
    								name : 'MS_PB',
    								data : [ 2, 0, 0, 0, 0 ]

    							}, {
    								name : 'Client',
    								data : [ 0, 1, 1, 2, 0 ]

    							} ]
    						});
    	}());

    	$(function() {
    		var chart;
    		$(document)
    				.ready(
    						function() {
    							// Build the chart4
    							$('#containerpie7')
    									.highcharts(
    											{
    												chart : {
    													plotBackgroundColor : null,
    													plotBorderWidth : null,
    													plotShadow : false
    												},
    												title : {
    													text : ''
    												},
    												tooltip : {
    													pointFormat : '{series.name}: <b>{point.percentage:.1f}%</b>'
    												},
    												plotOptions : {
    													pie : {
    														allowPointSelect : true,
    														cursor : 'pointer',
    														dataLabels : {
    															enabled : false
    														},
    														showInLegend : true
    													}
    												},
    												series : [ {
    													type : 'pie',
    													name : '',
    													data : [
    															[ 'Total Positions',
    																	526 ],
    															[ 'Unmapped Positions',
    																	2 ],
    															[
    																	'Pos. w Quantity breaks',
    																	4 ] ]
    												} ]
    											});
    						});

    	});
    	$(function() {
    		var chart;
    		$(document)
    				.ready(
    						function() {
    							// Build the chart4
    							$('#containerpie8')
    									.highcharts(
    											{
    												chart : {
    													plotBackgroundColor : null,
    													plotBorderWidth : null,
    													plotShadow : false
    												},
    												title : {
    													text : ''
    												},
    												tooltip : {
    													pointFormat : '{series.name}: <b>{point.percentage:.1f}%</b>'
    												},
    												plotOptions : {
    													pie : {
    														allowPointSelect : true,
    														cursor : 'pointer',
    														dataLabels : {
    															enabled : false
    														},
    														showInLegend : true
    													}
    												},
    												series : [ {
    													type : 'pie',
    													name : '',
    													data : [
    															[ 'Total cash items',
    																	21 ],
    															[ 'Unmapped Positions',
    																	2 ],
    															[
    																	'Pos. w Quantity breaks',
    																	3 ] ]
    												} ]
    											});
    						});

    	});

    	$(function() {
    		$('#containerproduct').highcharts(
    				{
    					chart : {
    						type : 'bar'
    					},

    					title : {
    						text : ''
    					},
    					subtitle : {
    						text : ''
    					},

    					xAxis : {
    						categories : [ 'CFD', 'CDS', 'Futures', 'IRS', 'Bonds',
    								'Eq Options' ]
    					},
    					credits : {
    						enabled : false
    					},
    					series : [ {
    						name : 'Product',
    						data : [ -10598, 503000000, 20665, 96000000, 329500000,
    								27750 ]

    					} ]
    				});
    	});

    	$(function() {
    		$('#containerproduct1').highcharts(
    				{
    					chart : {
    						type : 'bar'
    					},
    					title : {
    						text : ''
    					},
    					xAxis : {
    						categories : [ 'Bonds', 'CDS', 'CFD', 'Eq Options',
    								'Futures', 'IRS' ]
    					},
    					credits : {
    						enabled : false
    					},
    					series : [ {
    						name : '',
    						data : [ -4352714, -4217036, -394011, -34554, -37195,
    								-193548 ]
    					} ]
    				});
    	});
    	/*
    	 * $(function () { $('#container').highcharts({ chart: { type: 'area' }, title: {
    	 * text: 'Area chart with negative values' }, xAxis: { categories: ['Apples',
    	 * 'Oranges', 'Pears', 'Grapes', 'Bananas'] }, credits: { enabled: false },
    	 * series: [{ name: 'John', data: [5, 3, 4, 7, 2] }] }); });
    	 */

    	/*
    	 * $(function () { $('#containerpie4').highcharts({ chart: { type: 'column' },
    	 * title: { text: '' }, subtitle: { text: '' }, xAxis: { categories: [ 'Equity',
    	 * 'Eq Swaps', 'CDS', 'Futures'
    	 * 
    	 *  ] }, yAxis: { min: 0, title: { text: '' } }, tooltip: { headerFormat: '<span
    	 * style="font-size:10px">{point.key}</span><table>', pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}:
    	 * </td>' + '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
    	 * footerFormat: '</table>', shared: true, useHTML: true }, plotOptions: {
    	 * column: { pointPadding: 0.2, borderWidth: 0 } }, series: [{ name: 'RISK
    	 * REPORTING', data: [10, 69, 21, 110]
    	 *  }] }); });
    	 */
    	/*$(function() {
    		$('#areachart')
    				.highcharts(
    						{
    							chart : {
    								type : 'area'
    							},
    							title : {
    								text : ''
    							},
    							xAxis : {
    								categories : [ '01-Jul', '30-Jun', '29-Jun',
    										'28-Jun', '27-Jun', '26-Jun', '25-Jun',
    										'24-Jun', '23-Jun', '22-Jun', '21-Jun',
    										'20-Jun', '19-Jun', '18-Jun', '17-Jun',
    										'16-Jun', '15-Jun', '14-Jun', '13-Jun',
    										'12-Jun', '11-Jun', '10-Jun', '09-Jun',
    										'08-Jun', '07-Jun', '06-Jun', '05-Jun',
    										'04-Jun', '03-Jun', '02-Jun', '01-Jun',
    										'31-May', '30-May' ,'29-May','28-May','27-May','26-May','25-May','24-May','23-May','22-May','21-May','20-May','19-May','18-May','17-May','16-May','15-May','14-May','13-May','12-May','11-May','10-May','09-May','08-May','07-May','06-May','05-May','04-May','03-May','02-May','01-May','30-Apr','29-Apr','28-Apr','27-Apr','26-Apr','25-Apr','24-Apr','23-Apr','22-Apr','21-Apr','20-Apr','19-Apr','18-Apr','17-Apr','16-Apr','15-Apr','14-Apr','13-Apr','12-Apr','11-Apr','10-Apr','09-Apr','08-Apr','07-Apr','06-Apr','05-Apr','04-Apr','03-Apr','02-Apr','01-Apr','31-Mar','30-Mar','29-Mar','28-Mar','27-Mar','26-Mar','25-Mar','24-Mar','23-Mar','22-Mar','21-Mar','20-Mar','19-Mar','18-Mar','17-Mar','16-Mar','15-Mar','14-Mar','13-Mar','12-Mar','11-Mar','10-Mar','09-Mar','08-Mar','07-Mar','06-Mar','05-Mar','04-Mar','03-Mar','02-Mar','01-Mar','28-Feb','27-Feb','26-Feb','25-Feb','24-Feb','23-Feb','22-Feb','21-Feb','20-Feb','19-Feb','18-Feb','17-Feb','16-Feb','15-Feb','14-Feb','13-Feb','12-Feb','11-Feb','10-Feb','09-Feb','08-Feb','07-Feb','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','22-Jun','22-Jun','22-Jun','22-Jun','21-Jun','20-Jun','19-Jun','18-Jun','17-Jun','16-Jun','15-Jun','14-Jun','13-Jun','12-Jun','11-Jun','10-Jun','09-Jun','08-Jun','07-Jun','06-Jun','05-Jun','04-Jun','03-Jun','02-Jun','01-Jun','31-May','30-May','29-May','28-May','27-May','26-May','25-May','24-May','23-May','22-May','21-May','20-May','19-May','18-May','17-May','16-May','15-May','14-May','13-May','12-May','11-May','10-May','09-May','08-May','07-May','06-May','05-May','04-May','03-May','02-May','01-May','30-Apr','29-Apr','28-Apr','27-Apr','26-Apr','25-Apr','24-Apr','23-Apr','22-Apr','21-Apr','20-Apr','19-Apr','18-Apr','17-Apr','16-Apr','15-Apr','14-Apr','13-Apr','12-Apr','11-Apr','10-Apr','09-Apr','08-Apr','07-Apr','06-Apr','05-Apr','04-Apr','03-Apr','02-Apr','01-Apr','31-Mar','30-Mar','29-Mar','28-Mar','27-Mar','26-Mar','25-Mar','24-Mar','23-Mar','22-Mar','21-Mar','20-Mar','19-Mar','18-Mar','17-Mar','16-Mar','15-Mar','14-Mar','13-Mar','12-Mar','11-Mar','10-Mar','09-Mar','08-Mar','07-Mar','06-Mar','05-Mar','04-Mar','03-Mar','02-Mar','01-Mar','28-Feb','27-Feb','26-Feb','25-Feb','24-Feb','23-Feb','22-Feb','21-Feb','20-Feb','19-Feb','18-Feb','17-Feb','16-Feb','15-Feb','14-Feb','13-Feb','12-Feb','11-Feb','10-Feb','09-Feb','08-Feb','07-Feb','06-Feb','05-Feb','04-Feb','03-Feb','02-Feb','01-Feb','31-Jan','30-Jan','29-Jan','28-Jan','27-Jan','26-Jan','25-Jan','24-Jan','23-Jan','22-Jan','21-Jan','20-Jan','19-Jan','18-Jan','17-Jan','16-Jan','15-Jan','14-Jan','13-Jan','12-Jan','11-Jan','10-Jan','09-Jan','08-Jan','07-Jan','06-Jan','05-Jan','04-Jan','03-Jan','02-Jan','01-Jan','31-Dec','30-Dec','29-Dec','28-Dec','27-Dec','26-Dec','25-Dec','24-Dec','23-Dec','22-Dec','02-May','02-May','01-May','30-Apr','29-Apr','28-Apr','27-Apr','26-Apr','25-Apr','24-Apr','23-Apr','22-Apr','21-Apr','20-Apr','19-Apr','18-Apr','17-Apr','16-Apr','15-Apr','14-Apr','13-Apr','12-Apr','11-Apr','10-Apr','09-Apr','08-Apr','07-Apr','06-Apr','05-Apr','04-Apr','03-Apr','02-Apr','01-Apr','31-Mar','30-Mar','29-Mar','28-Mar','27-Mar','26-Mar','25-Mar','24-Mar','23-Mar','22-Mar','21-Mar','20-Mar','19-Mar','18-Mar','17-Mar','16-Mar','15-Mar','14-Mar','13-Mar','12-Mar','11-Mar','10-Mar','09-Mar','08-Mar','07-Mar','06-Mar','05-Mar','04-Mar','03-Mar','02-Mar','01-Mar','28-Feb','27-Feb','26-Feb','25-Feb','24-Feb','23-Feb','22-Feb','21-Feb','20-Feb','19-Feb','18-Feb','17-Feb','16-Feb','15-Feb','14-Feb','13-Feb','12-Feb','11-Feb','10-Feb','09-Feb','08-Feb','07-Feb','06-Feb','05-Feb','04-Feb','03-Feb','02-Feb','01-Feb','22-Jun','22-Jun','21-Jun','05-Jun','06-Jun','11-Jun','22-Jun','22-Jun','22-Jun','22-Jun' ]
    							},
    							credits : {
    								enabled : false
    							},
    							series : [ {
    								name : 'YTD P&L',
    								data : [ -847, 479, 483, 485, 486, 487, 489, 490,
    										573, -1082, -1167, -1251, -1335, -1419,
    										-1502, -1585, -1668, -1751, -1833, -1915,
    										-1997, -2079, -2160, -2241, -1612, -1644,
    										-2315, -2639, 2721, 2625, -2703, -2869  ,-2947,-3024,-3101,-3295,-3378,3457,1579,1581,1588,1595,1602,1609,1617,17890,17350,16826,8157,15815,7662,111313,11493,13896,6716,9080,3754,12062,5806,7816,3216,10279,4919,6580,2689,17058,4048,2299,2893,3401,1912,2378,2758,1527,1866,2119,1144,1356,1483,763,849,850,383,343,218,5,-161,8,131,343,-3672,-2321,-3251,-4260,-2673,-3720,-4845,-3023,-4186,-5425,-3370,-4647,-6000,-3714,-5103,-6567,-4053,-5553,-7126,-4386,-5994,-7674,-4712,-6425,-8207,-5028,-6841,-8719,-5330,-7235,-9201,-5612,-7599,-9639,-5862,-7915,-10006,6280,-59087,-75683,-46505,-63468,-81163,-49796,-67859,-86655,-53092,-72256,-92154,-56393,69315,88499,11784,15882,14653,8932,-12094,-15347,-9344,-12640,-16024,-9748,-13174,-16689,-10145,-13702,-17345,-21875,-7300,-13200,151,-12530,-7300,-52,-63,-78,-94,-111,-131,-152,-175,-199,-227,-256,-288,-323,-361,-19,2,23,32,42,215,0,10,18,26,35,45,54,64,74,-298,0,-59,-1,-3,-3,-3,-3,-3,-2,-2,-2,6,5,5,5,5,5,5,4,4,4,4,3,-49,-54,-58,-64,-69,-75,-82,-1,-2,-4,-5,-7,-9,-11,-14,-16,-19,-22,-25,-28,-32,-36,-40,-45,-50,-55,-61,-67,-73,552,6,11,10,10,10,10,10,10,10,10,10,9,9,9,9,9,8,8,8,7,-5,-5,-5,-4,-4,-3,-3,-2,-2,-1,0,18270,1408,-1675,25,-3,0,0,1,2,3,4,5,6,7,8,9,10,12,13,15,17,19,21,23,25,28,31,34,37,40,44,48,52,-463,-6,-286,-275,-260,-245,-230,-216,-203,-189,-176,-164,-150,-137,-124,-112,-101,-90,-80,-70,-61,-52,-44,-36,-29,-22,-16,-10,-4,1,6,11,16,20,24,28,32,35,38,42,45,48,50,53,56,58,61,63,66,68,71,73,76,78,81,83,86,88,91,94,97,100,103,106,110,113,117,121,125,129,133,138,142,147,153,158,-1082,170,176,182,189,196,203,211,219,227,236,-243,-262,-283,-306,-330,-357,-385,-416,-450,-486,-525,-567,-612,-78,55,56,51,47,42,38,33,29,25,20,16,12,8,362,,-,,,,32,58,-46267,-3917,-2084,-1418,-1065,-840,-13225,-6352,-4174,-3091,-2435,-1990,-1666,-1416,-1218,-1054,-917,-800,-6572,-5327,-4439,-3770,2032,1973,1775,1618,-2503,-2572,-2638,-2705,-2773,-2841,-2909,-1011,-946,-1000,-1055,-1111,-1167,-1224,-1281,-1338,-1397,-5197,-5273,-5350,-5428,-5506,-5585,-5664,-5743,-5823,-5904,-5985,-6066,-6148,-5973,-1547,-6392,-6481,-6565,-6650,-6735,-6821,-6908,-6995,-7082,-7170,-7258,-7347,-7436,-7526,-7616,-7707,28404,36393,43643,-110261,-148494,-187465,-113588,-152929,-193010,18423,23086,27009,15097,-161801,21465,11770,14215,15920,8443,9779,-733688,5116,5343,4831 
    								]
    							} ]
    						});
    	});*/
    	// ---------Dashboard Static charts End here--------------//
        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'Fund', type: 'string' },
                 { name: 'Strategy', type: 'string' },
                 { name: 'secType', type: 'string' },
                 { name: 'Counterparty', type: 'string' },
                 { name: 'Curr', type: 'string' },
                 { name: 'Sec_Type', type: 'string' },
                 { name: 'Trade_Date', type: 'string' },
                 { name: 'Confirmed', type: 'string' },
                 { name: 'Quantity', type: 'string' },
                 { name: 'Cost_Price', type: 'string' },
                 { name: 'Cost', type: 'string' },
                 { name: 'Price', type: 'string' },
                 { name: 'MV', type: 'string' },
                 { name: 'PL_Today', type: 'string' },
                 { name: 'MTD_PL', type: 'string' },
                 { name: 'YTD_PL', type: 'string' },
                 { name: 'PL', type: 'string' }

            ], 
            url: 'assets/sampledata/P-LReport.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        };
       /* // create jqxDataTable.
        $("#ProfitLoss").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showstatusbar: true,
            statusbarheight: 50,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,
            
            columns: [
              { text: 'Fund', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Fund', pinned: true,  width: '10%', minWidth: 80 , pinned: true },
              { text: 'Strategy', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Strategy', width: '10%' , pinned: true },
              { text: 'Investment ID', dataField: 'secType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '10%' , pinned: true },
              { text: 'Counterparty / Custodian',columngroup: 'ProductDetails', dataField: 'Counterparty', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '10%', minWidth: 180  },
              { text: 'Curr', cellsAlign: 'center', align: 'center', dataField: 'Curr', width: '10%'},
              { text: 'Sec Type', cellsAlign: 'center', align: 'center', dataField: 'Sec_Type', width: '10%'},
              { text: 'Trade Date', cellsAlign: 'center', align: 'center', dataField: 'Trade_Date', width: '10%'},
              { text: 'Confirmed: Y/N', cellsAlign: 'center', align: 'center', dataField: 'Confirmed', width: '10%'},
              { text: 'Quantity', cellsAlign: 'center', align: 'center', dataField: 'Quantity', width: '10%'},
              { text: 'Cost Price', cellsAlign: 'center', align: 'center', dataField: 'Cost_Price', width: '10%', aggregates: ['sum']},
              { text: 'Cost', cellsAlign: 'center', align: 'center', dataField: 'Cost', width: '10%', aggregates: ['sum'] },
              { text: 'Price', cellsAlign: 'center', align: 'center', dataField: 'Price', width: '10%', aggregates: ['sum']},
              { text: 'MV', cellsAlign: 'center', align: 'center', dataField: 'MV', width: '10%'},
              { text: 'P&L Today', cellsAlign: 'center', align: 'center', dataField: 'PL_Today', width: '10%'},
              { text: 'MTD P&L', cellsAlign: 'center', align: 'center', dataField: 'MTD_PL', width: '10%', aggregates: ['sum']},
              { text: 'YTD P&L', cellsAlign: 'center', align: 'center', dataField: 'YTD_PL', width: '10%', aggregates: ['sum']},
              { text: 'P&L (since TD)', cellsAlign: 'center', align: 'center', dataField: 'PL', width: '10%'}
            ]
            
        });  */
    
        
        // prepare the data
        var source =
        {
            dataType: "csv",
            dataFields: [
                 { name: 'Fund', type: 'string' },
                 { name: 'Strategy', type: 'string' },
                 { name: 'secType', type: 'string' },
                 { name: 'Counterparty', type: 'string' },
                 { name: 'Curr', type: 'string' },
                 { name: 'Sec_Type', type: 'string' },
                 { name: 'Trade_Date', type: 'string' },
                 { name: 'Confirmed', type: 'string' },
                 { name: 'Quantity', type: 'string' },
                 { name: 'Cost_Price', type: 'string' },
                 { name: 'Cost', type: 'string' },
                 { name: 'Price', type: 'string' },
                 { name: 'MV', type: 'string' },
                 { name: 'PL_Today', type: 'string' },
                 { name: 'MTD_PL', type: 'string' },
                 { name: 'YTD_PL', type: 'string' },
                 { name: 'PL', type: 'string' },
                 { name: 'VAR', type: 'string' }

            ], 
            url: 'assets/sampledata/VarReport.csv'
        };
        var dataAdapter = new $.jqx.dataAdapter(source, {
            loadComplete: function () {
                // data is loaded.
            }
        });
        var cellClass = function (row, dataField, cellText, rowData) {
            var cellValue = rowData[dataField];
            switch (dataField) {
                case "diffQuantity":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                       
                    return "max";
                    
                case "diffMarketValue":
                    if (cellValue >100 || cellValue < 0) {
                        return "minavg";                            
                    }
                    if (cellValue <= 100 ) {
                        return "max";
                    }                        
                    return "min";                    
            }
        }
        // create jqxDataTable.
        $("#var").jqxGrid(
        {
            source: dataAdapter,
            altRows: true,
            width: '99%',
            height: '600',
            sortable: true,
            pageable:false,
            filterable: true,
            groupable: true,
            showstatusbar: true,
            statusbarheight: 50,
            showaggregates: true,
            columnsresize: true,
            columnsreorder: true,
            
            columns: [
              { text: 'Fund', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Fund',/* pinned: true,*/  width: '10%', minWidth: 80 },
              { text: 'Strategy', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'Strategy', width: '10%' },
              { text: 'Investment ID', dataField: 'secType',columngroup: 'ProductDetails', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: '10%' },
              { text: 'Counterparty / Custodian',columngroup: 'ProductDetails', dataField: 'Counterparty', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: '10%', minWidth: 180  },
              { text: 'Curr', cellsAlign: 'center', align: 'center', dataField: 'Curr', width: '10%'},
              { text: 'Sec Type', cellsAlign: 'center', align: 'center', dataField: 'Sec_Type', width: '10%'},
              { text: 'Trade Date', cellsAlign: 'center', align: 'center', dataField: 'Trade_Date', width: '10%'},
              { text: 'Confirmed: Y/N', cellsAlign: 'center', align: 'center', dataField: 'Confirmed', width: '10%'},
              { text: 'Quantity', cellsAlign: 'center', align: 'center', dataField: 'Quantity', width: '10%'},
              { text: 'Cost Price', cellsAlign: 'center', align: 'center', dataField: 'Cost_Price', width: '10%', aggregates: ['sum']},
              { text: 'Cost', cellsAlign: 'center', align: 'center', dataField: 'Cost', width: '10%', aggregates: ['sum'] },
              { text: 'Price', cellsAlign: 'center', align: 'center', dataField: 'Price', width: '10%', aggregates: ['sum']},
              { text: 'MV', cellsAlign: 'center', align: 'center', dataField: 'MV', width: '10%'},
              { text: 'P&L Today', cellsAlign: 'center', align: 'center', dataField: 'PL_Today', width: '10%'},
              { text: 'MTD P&L', cellsAlign: 'center', align: 'center', dataField: 'MTD_PL', width: '10%', aggregates: ['sum']},
              { text: 'YTD P&L', cellsAlign: 'center', align: 'center', dataField: 'YTD_PL', width: '10%', aggregates: ['sum']},
              { text: 'P&L (since TD)', cellsAlign: 'center', align: 'center', dataField: 'PL', width: '10%'},
              { text: 'VAR', cellsAlign: 'center', align: 'center', dataField: 'VAR', width: '10%'}
            ]
            
        });  
    });

    
    /** Static Charts - End **/
        
  $(document).ready(function(){
	  
	  function insertDataReloadDiv(element){
			 $(element).append('<div class="loaddiv"></div>');
		}
	  
	  $.getJSON(
				ezopsContextPath
						+ '/getReports/getcashbyclearerchart',
				function(data) {
						getCashByClearerDrillDownChart(data);
		});
	  $("#Report_CashByClearerRefresh").on('click', function(element){
		  		insertDataReloadDiv(element.currentTarget);
		  		$.getJSON(
						ezopsContextPath
								+ '/getReports/getcashbyclearerchart?refresh=true',
						function(data) {
								getCashByClearerDrillDownChart(data);
								$('.loaddiv').hide();
				});
	  });
	function getCashByClearerDrillDownChart(data){
		
		   $('#CashByClearerChart').highcharts({
		        chart: {
		            type: 'line'
		        },
		        title: {
		            text: ''
		        },
		        subtitle: {
		            text: ''
		        },
		        xAxis: {
		            type: 'category',
		            //categories: data[2]
		        },
		        yAxis: {
		            title: {
		                text: 'Cash Amount'
		            }
		        },
		        legend: {
		            enabled: true
		        },
		        plotOptions: {
		            series: {
		                borderWidth: 0,
		                dataLabels: {
		                    // enabled: true
		                    //distance: -30,
		                    format: '{point.y:.1f}'
		                }
		            }
		        },

		        tooltip: {
		            headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
		            pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}</b> <br/>'
		        },

		        series: data[0],

		        drilldown: {
		            series: data[1].drilldownData
		        }
		    });

	}  
	  /*$(function () {

		 		}());
*/	  
  	/* Cash Balance Chart grid source*/
	  var cashClearerDataSource = null;
	  var cashClearerDataHeaderSource = null;
  	$.ajax({
  		'async': false,
  		'global': false,
  		'url': ezopsContextPath+"/getReports/getcashbyclearerdetailsfirstgrid",
  		'datatype': "json",
  		'success': function(data){
  			cashClearerDataSource = data.reportDataList;
  			cashClearerDataHeaderSource=data.columsList;
  			//console.log(cashClearerDataSource);
  		}            
		});
	 // console.log("cashClearerDataSource&&&& "+cashClearerDataSource);
      var source1 =
   	{
       dataType: "json",
       dataFields: [
            { name: 'currency', type: 'string' },
            { name: 'glAccount', type: 'string' },
            { name: 'date1', type: 'string' },
            { name: 'date2', type: 'string' },
            { name: 'date3', type: 'string' },
            { name: 'date4', type: 'string' },
            { name: 'date5', type: 'string' }
       ], 
       localdata:cashClearerDataSource 
       //url: ezopsContextPath+'/getReports/getcashbyclearerdetailsfirstgrid'
   };
   var dataAdapter1 = new $.jqx.dataAdapter(source1, {
       loadComplete: function () {
           // data is loaded.
       }
   });
   var cellClass = function (row, dataField, cellText, rowData) {
       var cellValue = rowData[dataField];
       switch (dataField) {
           case "diffQuantity":
               if (cellValue >100 || cellValue < 0) {
                   return "minavg";                            
               }
               if (cellValue <= 100 ) {
                   return "max";
               }                       
               return "max";
               
           case "diffMarketValue":
               if (cellValue >100 || cellValue < 0) {
                   return "minavg";                            
               }
               if (cellValue <= 100 ) {
                   return "max";
               }                        
               return "min";                    
       }
   };
   $("#CashByClearerGrid1").jqxGrid(
    	    {
    	        source: dataAdapter1,
    	        altRows: true,
                width: '99%',
                height: '600',
                sortable: true,
                pageable:false,
                filterable: true,
                groupable: true,
                showstatusbar: true,
                statusbarheight: 50,
                showaggregates: true,
                columnsresize: true,
                columnsreorder: true,

    	        
    	        columns: [
    	          	 { text: 'Currency', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'currency', width: '10%'},
    	             { text: 'GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'glAccount', width: '25%'},
    	             { text: cashClearerDataHeaderSource[2], cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'date1', width: '13%'},
    	             { text: cashClearerDataHeaderSource[3], cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'date2', width: '13%'},
    	             { text: cashClearerDataHeaderSource[4], cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'date3', width: '13%'},
    	             { text: cashClearerDataHeaderSource[5], cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'date4', width: '13%'},
    	             { text: cashClearerDataHeaderSource[6], cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'date5', width: '13%'} 	        
    	            ]
    	    }); 
   	
   			//$("#CashByClearerGrid1").jqxGrid('setcolumnproperty', 'date1', 'text', cashClearerDataHeaderSource[2]);
   
        	/* Cash Balance Chart grid source*/
            var source2 =
         	{
             dataType: "json",
             dataFields: [
                  { name: 'valueDate', type: 'string' },
                  { name: 'bookId', type: 'string' },
                  { name: 'tradeId', type: 'string' },
                  { name: 'cashCurrency', type: 'string' },
                  { name: 'productDescription', type: 'string' },
                  { name: 'status', type: 'string' },
                  { name: 'cashAmount', type: 'string' },
                  { name: 'realSettlementDate', type: 'string' },
                  { name: 'cashPayReceive', type: 'string' },
                  { name: 'securityAmount', type: 'string' },
                  { name: 'securityPayReceive', type: 'string' },
                  { name: 'underlyingProductDescription', type: 'string' },
                  { name: 'paymentCategory', type: 'string' },
                  { name: 'productGroup', type: 'string' },
                  { name: 'action', type: 'string' },
                  { name: 'paymentComment', type: 'string' },
                  { name: 'matchingDescription', type: 'string' },
                  { name: 'entityCashInstructionSSI', type: 'string' },
                  { name: 'partyCashInstructionSSI', type: 'string' },
                  { name: 'entitySecurityInstructionSSI', type: 'string' },
                  { name: 'partySecurityInstructionSSI', type: 'string' },
                  { name: 'id', type: 'string' },
                  { name: 'version', type: 'string' },
                  { name: 'quantity', type: 'string' },
                  { name: 'securityUnit', type: 'string' },
                  { name: 'securityId', type: 'string' },
                  { name: 'deliveryMethod', type: 'string' },
                  { name: 'sourceEventId', type: 'string' },
                  { name: 'nettingType', type: 'string' },
                  { name: 'nettingId', type: 'string' },
                  { name: 'bookingDate', type: 'string' },
                  { name: 'partyId', type: 'string' },
                  { name: 'gLAccount', type: 'string' },
                  { name: 'parentPaymentId', type: 'string' },
                  { name: 'reversePaymentId', type: 'string' },
                  { name: 'settlementMethod', type: 'string' },
                  { name: 'knownDate', type: 'string' },
                  { name: 'partyInstructionStatus', type: 'string' },
                  { name: 'entityInstructionStatus', type: 'string' },
                  { name: 'isCashOnly', type: 'string' },
                  { name: 'isSecurityOnly', type: 'string' },
                  { name: 'clearerId', type: 'string' },
                  { name: 'securityGLAccount', type: 'string' },
                  { name: 'securitGLAccountName', type: 'string' },
                  { name: 'clearerPartyId', type: 'string' },
                  { name: 'entityAgentPartyId', type: 'string' },
                  { name: 'entityPartyId', type: 'string' },
                  { name: 'paymentType', type: 'string' },
                  { name: 'settledCashAmount', type: 'string' },
                  { name: 'settledSecurityQuantity', type: 'string' },
                  { name: 'updateTime', type: 'string' },
                  { name: 'matchingType', type: 'string' },
                  { name: 'importRef', type: 'string' },
                  { name: 'isInternal', type: 'string' },
                  { name: 'underlyingProcessingType', type: 'string' },
                  { name: 'parentClearerId', type: 'string' }
             ], 
             url: ezopsContextPath+'/getReports/getcashbyclearerdetailssecondgrid'
         };
         var dataAdapter2 = new $.jqx.dataAdapter(source2, {
             loadComplete: function () {
                 // data is loaded.
             }
         });
         var cellClass = function (row, dataField, cellText, rowData) {
             var cellValue = rowData[dataField];
             switch (dataField) {
                 case "diffQuantity":
                     if (cellValue >100 || cellValue < 0) {
                         return "minavg";                            
                     }
                     if (cellValue <= 100 ) {
                         return "max";
                     }                       
                     return "max";
                     
                 case "diffMarketValue":
                     if (cellValue >100 || cellValue < 0) {
                         return "minavg";                            
                     }
                     if (cellValue <= 100 ) {
                         return "max";
                     }                        
                     return "min";                    
             }
         };
         $("#CashByClearerGrid2").jqxGrid(
                 	    {
                 	        source: dataAdapter2,
                 	        altRows: true,
                             width: '99%',
                             height: '600',
                             sortable: true,
                             pageable:false,
                             filterable: true,
                             groupable: true,
                             showstatusbar: true,
                             statusbarheight: 50,
                             showaggregates: true,
                             columnsresize: true,
                             columnsreorder: true,

                 	        
                 	        columns: [
                 	          	 { text: 'Value Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'valueDate', width: '100px'},
                 	             { text: 'Book Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookId', width: '100px'},
                 	             { text: 'Trade Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'tradeId', width: '100px'},
                 	             { text: 'Cash Currency', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashCurrency', width: '100px'},
                 	             { text: 'Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productDescription', width: '100px'},
                 	             { text: 'Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'status', width: '100px'},
                 	             { text: 'Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashAmount', width: '100px'},
                 	             { text: 'Real Settlement Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'realSettlementDate', width: '100px'},
                 	             { text: 'Cash Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'cashPayReceive', width: '100px'},
                 	             { text: 'Security Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityAmount', width: '100px'},
                 	             { text: 'Security Pay Receive', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityPayReceive', width: '100px'},
                 	             { text: 'Underlying Product Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProductDescription', width: '100px'},
                 	             { text: 'Payment Category', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentCategory', width: '100px'},
                 	             { text: 'Product Group', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'productGroup', width: '100px'},
                 	             { text: 'Action', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'action', width: '100px'},
                 	             { text: 'Payment Comment', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentComment', width: '100px'},
                 	             { text: 'Matching Description', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingDescription', width: '100px'},
                 	             { text: 'Entity Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityCashInstructionSSI', width: '100px'},
                 	             { text: 'Party Cash Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyCashInstructionSSI', width: '100px'},
                 	             { text: 'Entity Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entitySecurityInstructionSSI', width: '100px'},
                 	             { text: 'Party Security Instruction SSI', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partySecurityInstructionSSI', width: '100px'},
                 	             { text: 'Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'id', width: '100px'},
                 	             { text: 'Version', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'version', width: '100px'},
                 	             { text: 'Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'quantity', width: '100px'},
                 	             { text: 'Security Unit', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityUnit', width: '100px'},
                 	             { text: 'Security Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityId', width: '100px'},
                 	             { text: 'Delivery Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'deliveryMethod', width: '100px'},
                 	             { text: 'Source Event Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'sourceEventId', width: '100px'},
                 	             { text: 'Netting Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingType', width: '100px'},
                 	             { text: 'Netting Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'nettingId', width: '100px'},
                 	             { text: 'Booking Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'bookingDate', width: '100px'},
                 	             { text: 'Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyId', width: '100px'},
                 	             { text: 'GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'gLAccount', width: '100px'},
                 	             { text: 'Parent Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentPaymentId', width: '100px'},
                 	             { text: 'Reverse Payment Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'reversePaymentId', width: '100px'},
                 	             { text: 'Settlement Method', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settlementMethod', width: '100px'},
                 	             { text: 'Known Date', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'knownDate', width: '100px'},
                 	             { text: 'Party Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'partyInstructionStatus', width: '100px'},
                 	             { text: 'Entity Instruction Status', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityInstructionStatus', width: '100px'},
                 	             { text: 'Is Cash Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isCashOnly', width: '100px'},
                 	             { text: 'Is Security Only', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isSecurityOnly', width: '100px'},
                 	             { text: 'Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerId', width: '100px'},
                 	             { text: 'Security GL Account', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securityGLAccount', width: '100px'},
                 	             { text: 'Security GL Account Name', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'securitGLAccountName', width: '100px'},
                 	             { text: 'Clearer Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'clearerPartyId', width: '100px'},
                 	             { text: 'Entity Agent Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityAgentPartyId'},
                 	             { text: 'Entity Party Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'entityPartyId', width: '100px'},
                 	             { text: 'Payment Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'paymentType', width: '100px'},
                 	             { text: 'Settled Cash Amount', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledCashAmount', width: '100px'},
                 	             { text: 'Settled Security Quantity', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'settledSecurityQuantity', width: '100px'},
                 	             { text: 'Update Time', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'updateTime', width: '100px'},
                 	             { text: 'Matching Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'matchingType', width: '100px'},
                 	             { text: 'Import Ref', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'importRef', width: '100px'},
                 	             { text: 'Is Internal', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'isInternal', width: '100px'},
                 	             { text: 'Underlying Processing Type', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'underlyingProcessingType', width: '100px'},
                 	             { text: 'Parent Clearer Id', cellsAlign: 'center',columngroup: 'ProductDetails', align: 'center', dataField: 'parentClearerId', width: '100px'}
                 	        ]
                 	    }); 
        	
        });